home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.programmer
- 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
- From: dkeisen@leland.Stanford.EDU (Dave Eisen)
- Subject: Re: Creating a background process from within C prog
- Message-ID: <1992Nov12.020913.19659@leland.Stanford.EDU>
- Sender: news@leland.Stanford.EDU (Mr News)
- Organization: Sequoia Peripherals, Inc.
- References: <HUANG1.92Nov10171831@husc10.harvard.edu> <1992Nov11.032950.23086@leland.Stanford.EDU> <1992Nov12.003035.24322@tc.cornell.edu>
- Date: Thu, 12 Nov 92 02:09:13 GMT
- Lines: 36
-
- In article <1992Nov12.003035.24322@tc.cornell.edu> mdw@theory.TC.Cornell.EDU (Matt Welsh) writes:
- >In article <1992Nov11.032950.23086@leland.Stanford.EDU> dkeisen@leland.Stanford.EDU (Dave Eisen) writes:
- >>If you're going to use system, you might as well take the shell
- >>you spawn for all it's worth and write:
- >>
- >> system ("ls > /tmp/myfile &");
- >
- >Um, why? The process running the system is fork()ed from the parent, which
- >isn't neccesarily wait()ing for the child to finish. That won't buy you
- >much (unless I'm very confused :)).
-
-
- No no no.... Do the system in the parent. My point is that
- if you are going to do a "system", there is no reason to
- fork in the parent. The system statement above runs ls
- in the background without having to do any explicit forks.
-
- I said to replace:
-
- kiddo = fork ();
- if (kiddo == 0) {
- system ("ls > /tmp/myfile");
- exit (0);
- }
-
- with
-
- system ("ls > /tmp/myfile &");
-
-
-
- --
- Dave Eisen Sequoia Peripherals: (415) 967-5644
- dkeisen@leland.Stanford.EDU Home: (415) 321-5154
- There's something in my library to offend everybody.
- --- Washington Coalition Against Censorship
-