Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!cs.utexas.edu!uunet!bria!mike From: mike@bria.UUCP (mike.stefanik) Newsgroups: comp.unix.programmer Subject: Re: how to change parent environment? Message-ID: <242@bria.UUCP> Date: 4 May 91 04:50:22 GMT References: <1991May2.194624.21819@kong.gsfc.nasa.gov> Reply-To: uunet!bria!mike Distribution: usa Organization: MGI Group International, Los Angeles, CA Lines: 22 In an article, njacobs@kong.gsfc.nasa.gov (Nick Jacobs - EOS) writes: |How do you change the current working directory in a program, so |that when the program is invoked from a shell, the cwd stays |changed after the program exits? | |You can't do it with chdir(2) of course, because that only affects |the current process. Seems that you have answered your own question. The current working directory is unique to each process. It is inherited in only one direction -- parent to child. Yes, yes, you could go read the kernel namelist, search the proc table, read and modify the u area of the parent. Of course, it is unportable, requires root privilege, subject to races with the kernel, and is generally bletcherous. So, that's not really an option -- is it? -- Michael Stefanik, MGI Inc, Los Angeles | Opinions stated are never realistic Title of the week: Systems Engineer | UUCP: ...!uunet!bria!mike ------------------------------------------------------------------------------- If MS-DOS didn't exist, who would UNIX programmers have to make fun of?