Date: Sat, 26 Jun 1999 16:28:21 +0200 (MET DST) From: Lukas Ruf <lpruf@stud.ee.ethz.ch> To: Peihan Wang <peihanw@mx.cei.gov.cn> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: char* getenv(const char*) (3) Message-ID: <Pine.GSO.4.10.9906261622150.562-100000@tardis-a2.ee.ethz.ch> In-Reply-To: <3774E0F2.66FECA2D@mx.cei.gov.cn>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Peihan, On Sat, 26 Jun 1999, Peihan Wang wrote: > But there is something I can not explain. Me neither. > The code > char * cp = getenv("PATH"); > works fine, > while other two usage > cp = getenv("PPID"); > cp = getenv("PIPESTATUS"); > just return NULL. > > Under shell(bash2.01), I type > $ set > ... > PATH=/sbin:/usr/sbin:/bin:/usr/bin.... > PIPESTATUS=([0]="0") > PPID=258 > ... > $ echo $PPID > 258 > $ echo $PIPESTATUS > 0 > > Why getenv does not work with PPID & PIPESTATUS ? > How shell obtain these info ? > I suppose, that these environment variables are set upon request, i.e. they do not really exist but are set by the bash when their state is requested. You know for sure about the existence of the getppid() function ? Within a process table as displayed by ps, the PPID can be obtained. I think, but I am not sure, that the same applies to the PIPESTATUS. Take a look at the source code of ps ! Kind regards, Lukas -- *** ALWAYS MAILTO:"Lukas Ruf <lpruf@stud.ee.ethz.ch>" *** (PGP2.6.3) Fingerprint = 37CF 3AB4 B0F7 0AF5 C308 4188 8C10 86FE To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.9906261622150.562-100000>