From owner-freebsd-questions Sat Jun 26 7:28:27 1999 Delivered-To: freebsd-questions@freebsd.org Received: from stud.ee.ethz.ch (tardis-delek-fast.ee.ethz.ch [129.132.2.199]) by hub.freebsd.org (Postfix) with ESMTP id E6A6014D71 for ; Sat, 26 Jun 1999 07:28:24 -0700 (PDT) (envelope-from lpruf@stud.ee.ethz.ch) Received: from tardis-a2.ee.ethz.ch (lpruf@tardis-a2.ee.ethz.ch [129.132.3.12]) by stud.ee.ethz.ch (8.8.4/8.8.8) with ESMTP id QAA17171; Sat, 26 Jun 1999 16:28:23 +0200 (MET DST) Received: from localhost (lpruf@localhost) by tardis-a2.ee.ethz.ch (8.8.4/8.8.8) with ESMTP id QAA01890; Sat, 26 Jun 1999 16:28:21 +0200 (MET DST) X-Authentication-Warning: tardis-a2.ee.ethz.ch: lpruf owned process doing -bs Date: Sat, 26 Jun 1999 16:28:21 +0200 (MET DST) From: Lukas Ruf X-Sender: lpruf@tardis-a2.ee.ethz.ch Reply-To: Lukas Ruf To: Peihan Wang Cc: freebsd-questions@FreeBSD.ORG Subject: Re: char* getenv(const char*) (3) In-Reply-To: <3774E0F2.66FECA2D@mx.cei.gov.cn> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 " *** (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