Killing a background process from a C program

Tuong C. Truong truong at wk35..nas.nasa.gov
Tue Jul 24 03:32:36 AEST 1990


In article <1990Jul19.201116.13696 at Neon.Stanford.EDU> dkeisen at Gang-of-Four.Stanford.EDU (Dave Eisen) writes:
>In article <1990Jul19.151728.17448 at ncs.dnd.ca> marwood at 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.
>>
>

Just off the top of my head, but you may want to try something like :

set PID = `background_process&`

at this point PID will keep track of the process ID of the background process.
later when you want to kill it, you may use something like:

kill -9 $PID

I have not tried this, but hope it works.

------------------------
Signature Under Construction.



More information about the Comp.unix.questions mailing list