home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / question / 15070 < prev    next >
Encoding:
Text File  |  1992-12-30  |  1.7 KB  |  44 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!ames!data.nas.nasa.gov!ace.nas.nasa.gov!jns
  3. From: jns@ace.nas.nasa.gov (John N. Stewart)
  4. Subject: Re: how to change shell's PWD(directory) from a C program?
  5. References: <1hqe2cINN6ot@usenet.INS.CWRU.Edu> <C02648.Jq@bc3.GUN.de>
  6. Sender: news@nas.nasa.gov (News Administrator)
  7. Organization: NAS, NASA Ames Research Center, Moffett Field, California
  8. Date: Wed, 30 Dec 92 23:59:28 GMT
  9. Message-ID: <1992Dec30.235928.8810@nas.nasa.gov>
  10. Lines: 32
  11.  
  12. In article <C02648.Jq@bc3.GUN.de> ktf@bc3.GUN.de (Klaus ter Fehn) writes:
  13. >In article <1hqe2cINN6ot@usenet.INS.CWRU.Edu> cl820@cleveland.Freenet.Edu (Wei Jin Mai) writes:
  14. >>    Here is what I want to do: UPon the termination of my program, I 
  15. >>want to change to another directory . Normally, a program exit to the
  16. >>directory that invoke it. 
  17. >
  18. >Because of the current newsgroup (comp.unix.questions) I assume, that
  19. >you're programming under the UNIX-environment. Note, that the PWD (Path
  20. >of Working Directory) is an environment-held information of a
  21. >process.
  22.  
  23.  
  24. No, actually it isn't. The PWD is a function of certain shells, not
  25. processes. You can't really assume it is there, or for that matter, it
  26. is dangerous to assume it is correct.
  27.  
  28. Frankly, changing the cwd of a parent process ain't "possible" from a
  29. child, since that child has no control over the parent (FAQ). The next
  30. best thing I can imagine is to have the parent process "cd" to a
  31. directory returned by the exit status or something of that nature.
  32. Something like:
  33.  
  34. Pseudo:
  35.  
  36. #!insert your favourite shell here
  37.  
  38. cd `program`
  39.  
  40.  
  41. where program returns the new directory to be "cd"'ed to.
  42.  
  43. --Ace
  44.