andrew@csd4.milw.wisc.edu (Andrew David Biewer) (04/27/88)
Hello, Doe anyone know how I can change my cwd from within a program (run as a process) so when I leave that process, the change is still made? I would like to be able to do it through C if possible. chdir(2) works to change the cwd but only within the program. Is there any other way? A*n*d*r*e*w
drears@ardec.arpa (Dennis G. Rears (FSAC)) (04/28/88)
Andrew: -> ->Hello, -> -> Doe anyone know how I can change my cwd from within a program ->(run as a process) so when I leave that process, the change is still ->made? I would like to be able to do it through C if possible. ->chdir(2) works to change the cwd but only within the program. Is ->there any other way? -> -> A*n*d*r*e*w -> There is no way to do it easily. Possible ways include interprocess communication between parent and child, or have the child write the new cwd to a file and have the parent read it and chdir. Other than that no. dgr -------------------------------------------------------------------------- ARPA: drears@ardec-ac4.arpa UUCP: ...!uunet!ardec-ac4.arpa!drears AT&T: 201-724-6639 Snailmail: Box 210, Wharton, NJ 07885 Flames: /dev/null Reincarnation: newton!babbage!patton!drears Work: SMCAR-FSS-E, Dennis Rears, Bldg 94, Picatinny Ars, NJ 07806 --------------------------------------------------------------------------
gwyn@brl-smoke.ARPA (Doug Gwyn ) (04/29/88)
In article <13144@brl-adm.ARPA> andrew@csd4.milw.wisc.edu (Andrew David Biewer) writes: >Doe anyone know how I can change my cwd from within a program >(run as a process) so when I leave that process, the change is still made? There is no reasonable way to do this; it's an intentional feature of the UNIX process design.
gandalf@csli.STANFORD.EDU (Juergen Wagner) (04/29/88)
The only solution to this would be passing some value back to the parent (who should expect this). In general, there is no way to modify the parent's environment. I suggest to use either a return value (caught after wait'ing for the child's death), or a pipe (possibly named in the UNIX domain), or if a special monitorable action causes the cd inside the child, let the parent monitor these actions, too, and react in the same way. -- Juergen "Gandalf" Wagner, gandalf@csli.stanford.edu Center for the Study of Language and Information (CSLI), Stanford CA