Xref: utzoo comp.unix.wizards:24126 comp.unix.sysv386:4965 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.unix.wizards,comp.unix.sysv386 Subject: Re: Putenv() & Getenv() Bug ? Message-ID: <1991Feb15.140309.17684@virtech.uucp> Date: 15 Feb 91 14:03:09 GMT References: <50358@olivea.atc.olivetti.com> Organization: Virtual Technologies Inc. Lines: 21 borzieri@KING.ICO.OLIVETTI.COM (Ivan Borzieri) writes: >in the first c module I call the system function "putenv()" which should >set a variable in the environment. >In the second c module I call the system function "getenv()" to read >the value of the previous set variable. the problem is *PROBABLY* that you are using a local variable in the call to putenv. local data is lost when you return from the function and thereafter unavailable. the putenv(3) man page states that you shouldn't do this. The argument to putenv should point to a static data area or a malloc'd data area. All this is predicated on the fact that both modules (the one calling putenv and the one calling getenv) are called from the same executable. -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc. uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170