Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!mimsy!oddjob!gargoyle!ihnp4!homxb!whuts!whuxm!davew From: davew@whuxm.UUCP (WONNACOTT) Newsgroups: comp.lang.c Subject: Re: Accessing argc/argv/envp Message-ID: <548@whuxm.UUCP> Date: Mon, 27-Jul-87 14:43:03 EDT Article-I.D.: whuxm.548 Posted: Mon Jul 27 14:43:03 1987 Date-Received: Wed, 29-Jul-87 01:03:15 EDT References: <22@flmis06.ATT.COM> <28700015@ccvaxa> <420@sugar.UUCP> Organization: AT&T Bell Laboratories Lines: 31 In article <420@sugar.UUCP>, peter@sugar.UUCP (Peter da Silva) writes: > In article <28700015@ccvaxa>, aglew@ccvaxa.UUCP writes: > > In standard C you cannot get access to argv/argc/envp without doing work > > in main(). > > getenv()? putenv()? execl()? execv()? execlp()? execvp()? > -- > -- Peter da Silva `-_-' ...!seismo!soma!uhnix1!sugar!peter (I said, NO PHOTOS!) getenv() and putenv() access an external variable extern char **environ; which starts out the same as envp, but may be changed by putenv(). You can also access environ directly from any function, but you cannot legally get at argc, argv, or envp (as I understand standard C, at least). By the way, you should not use envp after putenv(), as putenv() does not update envp (it can't). If you need to get at the entire table of environment variables after a putenv(), use environ instead. In fact, I've heard its a good idea to use environ instead of envp because non-un*x systems are more likely to have environ than envp. exec system calls do not access the argc and argv parameters of the process that started them. They do provide values which will become arguments to the program that gets exec-ed, but thats a different story. -- David Wonnacott "They said Van Gogh was crazy, didn't they?" whuxm!davew or rz3bb!davew AT&T Corporate Education The above opinions are not necessarily those of AT&T, or of anyone else anywhere