Xref: utzoo comp.lang.c:30394 comp.unix.questions:23893 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!usc!elroy.jpl.nasa.gov!ames!eos!shelby!neon!Gang-of-Four!dkeisen From: dkeisen@Gang-of-Four.Stanford.EDU (Dave Eisen) Newsgroups: comp.lang.c,comp.unix.questions Subject: Re: Killing a background process from a C program Message-ID: <1990Jul19.201116.13696@Neon.Stanford.EDU> Date: 19 Jul 90 20:11:16 GMT References: <1990Jul19.151728.17448@ncs.dnd.ca> Sender: news@Neon.Stanford.EDU (USENET News System) Followup-To: comp.unix.questions Organization: Sequoia Peripherals Lines: 27 In article <1990Jul19.151728.17448@ncs.dnd.ca> marwood@ncs.dnd.ca (Gordon Marwood) writes: > >What I would like to do is start a background process at one point in the >C program, and at a later time kill it. Currently I am invoking the >background process with system("background_process &");, but none of the >texts that I have available help me to proceed any further. > System is not a powerful enough tool for this, it is designed for only the simplest of process control situations. You'll have to fork and exec the new process yourself. Fork will create a new process and return the pid of that process, at some later point use kill (pid, signal_number) to kill it. For more details, drop me a note or (better still) pick up a copy of Marc Rochkind's Advanced Unix Programming. (BTW -- even though it is a UNIX book and not a C book, I think it should be mentioned in the Frequently Asked Questions posting as an excellent reference for C programming under UNIX.) Followups redirected to comp.unix.questions. -- Dave Eisen Home: (415) 323-9757 dkeisen@Gang-of-Four.Stanford.EDU Office: (415) 967-5644 1447 N. Shoreline Blvd. Mountain View, CA 94043