home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / programm / 5255 < prev    next >
Encoding:
Text File  |  1992-11-11  |  1.9 KB  |  48 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!iggy.GW.Vitalink.COM!cs.widener.edu!eff!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!stanford.edu!leland.Stanford.EDU!dkeisen
  3. From: dkeisen@leland.Stanford.EDU (Dave Eisen)
  4. Subject: Re: Creating a background process from within C prog
  5. Message-ID: <1992Nov12.020913.19659@leland.Stanford.EDU>
  6. Sender: news@leland.Stanford.EDU (Mr News)
  7. Organization: Sequoia Peripherals, Inc.
  8. References: <HUANG1.92Nov10171831@husc10.harvard.edu> <1992Nov11.032950.23086@leland.Stanford.EDU> <1992Nov12.003035.24322@tc.cornell.edu>
  9. Date: Thu, 12 Nov 92 02:09:13 GMT
  10. Lines: 36
  11.  
  12. In article <1992Nov12.003035.24322@tc.cornell.edu> mdw@theory.TC.Cornell.EDU (Matt Welsh) writes:
  13. >In article <1992Nov11.032950.23086@leland.Stanford.EDU> dkeisen@leland.Stanford.EDU (Dave Eisen) writes:
  14. >>If you're going to use system, you might as well take the shell
  15. >>you spawn for all it's worth and write:
  16. >>
  17. >>      system ("ls > /tmp/myfile &");
  18. >
  19. >Um, why? The process running the system is fork()ed from the parent, which 
  20. >isn't neccesarily wait()ing for the child to finish. That won't buy you
  21. >much (unless I'm very confused :)). 
  22.  
  23.  
  24. No no no.... Do the system in the parent. My point is that
  25. if you are going to do a "system", there is no reason to
  26. fork in the parent. The system statement above runs ls
  27. in the background without having to do any explicit forks.
  28.  
  29. I said to replace:
  30.  
  31.    kiddo = fork ();
  32.    if (kiddo == 0) {
  33.       system ("ls > /tmp/myfile");
  34.       exit (0);
  35.    }
  36.  
  37. with
  38.    
  39.    system ("ls > /tmp/myfile &");
  40.  
  41.  
  42.  
  43. -- 
  44. Dave Eisen                               Sequoia Peripherals: (415) 967-5644
  45. dkeisen@leland.Stanford.EDU              Home:                (415) 321-5154
  46.        There's something in my library to offend everybody. 
  47.           --- Washington Coalition Against Censorship
  48.