From owner-freebsd-hackers Mon Jun 28 19:43:22 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from allegro.lemis.com (allegro.lemis.com [192.109.197.134]) by hub.freebsd.org (Postfix) with ESMTP id 1B34515028 for ; Mon, 28 Jun 1999 19:43:16 -0700 (PDT) (envelope-from grog@freebie.lemis.com) Received: from freebie.lemis.com (freebie.lemis.com [192.109.197.137]) by allegro.lemis.com (8.9.1/8.9.0) with ESMTP id MAA21520; Tue, 29 Jun 1999 12:13:15 +0930 (CST) Received: (from grog@localhost) by freebie.lemis.com (8.9.3/8.9.0) id MAA85918; Tue, 29 Jun 1999 12:13:13 +0930 (CST) Date: Tue, 29 Jun 1999 12:13:13 +0930 From: Greg Lehey To: Patryk Zadarnowski Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: environment strings Message-ID: <19990629121313.B85121@freebie.lemis.com> References: <19990629095659.B86806@freebie.lemis.com> <199906290218.MAA29451@mycenae.ilion.eu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.4i In-Reply-To: <199906290218.MAA29451@mycenae.ilion.eu.org>; from Patryk Zadarnowski on Tue, Jun 29, 1999 at 12:18:07PM +1000 WWW-Home-Page: http://www.lemis.com/~grog X-PGP-Fingerprint: 6B 7B C3 8C 61 CD 54 AF 13 24 52 F8 6D A4 95 EF Organization: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-41-739-7062 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tuesday, 29 June 1999 at 12:18:07 +1000, Patryk Zadarnowski wrote: > >>> I wanted t know where the environment strings i bsd were stored after a >>> program execs another one. > > extern char **environ; > >> At the top of memory. You can access them by the standard (but >> undocumented) method: >> >> int main (int argc, char *argv [], char *envp []) >> >> envp is a pointer to the environment strings. This is true for every >> version of UNIX I know. > > This is of course correct except for the `undocumented' claim. The > `envp' has been documented as the third argument to main() since the > Pharaons (well, not quite ;). Apparently AT&T UNIX even has a > (documented) five-parameter main(). This is news to me. Can you point to the documentation? > Besides, the `envp' argument is a recommended extension in ISO/ANSI > C, so you can hardly say that it's undocumented. Hmm. I don't have the Standard here, but I've dug around and found a couple of references to the third parameter, an "optional extension". I think the real problem is that K&R didn't describe it: it was introduced in the Seventh Edition, which came after K&R. Greg -- See complete headers for address, home page and phone numbers finger grog@lemis.com for PGP public key To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message