home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20321 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.6 KB  |  37 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!europa.eng.gtefsd.com!darwin.sura.net!newsserver.jvnc.net!yale.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!news.funet.fi!hydra!klaava!wirzeniu
  3. From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
  4. Subject: Re: Where does system("cd ./sudir") go ?
  5. Message-ID: <1993Jan28.172809.4614@klaava.Helsinki.FI>
  6. Organization: University of Helsinki
  7. References: <C1JMDn.9Gw@acsu.buffalo.edu>
  8. Date: Thu, 28 Jan 1993 17:28:09 GMT
  9. Lines: 26
  10.  
  11. zshi@acsu.buffalo.edu (Zhixin Shi) writes:
  12. >    I tried to make a program using system call to change dir, but when
  13. >I use
  14. >            system("cd ./sudir")
  15. >it looks like going into the subdir then come back when the program
  16. >finished.
  17.  
  18. The details of how system() works depend on the implementation and the
  19. environment where the program is run.  On most systems, system()
  20. starts a new program (command interpreter or shell) to execute the
  21. command given to it.  On some system, when the shell (or whatever)
  22. changes _its_ work directory, it doesn't affect any other program.
  23. This is the case with Unix, for example (your example would indicate
  24. Unix, or something very similar).  On other systems (MS-DOS, for
  25. example) it _does_ affect, and changes the work directory for all
  26. programs.
  27.  
  28. >    Is there any idea how to make the program stay into the subdir or 
  29. >simply using some other calls to do this?
  30.  
  31. There is no portable way.  Under Unix and MS-DOS, look for the chdir()
  32. function.
  33.  
  34. --
  35. Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
  36.    MS-DOS, you can't live with it, you can live without it.
  37.