Re: Killing another process from C code
From: Kasper Dupont (kasperd_at_daimi.au.dk)
Date: Wed, 17 Mar 2004 13:48:50 +0100
"Basile Starynkevitch [news]" wrote:
> The application should remember forked pids. The parent process
> should, when fork()-ing, remember the child pid and then kill it
Yes, when you know the pid there is no point in
using other unreliable ways to try guessing which
process is the right one to kill.
> Hence the parent is able to use the kill system call
> kill(pid,SIGTERM) and then kill(pid, SIGKILL).
That is the way to do it. You should add a delay
between the two calls so the process have a chance
to shut down cleanly (if by any means possible).
I'm not sure what is the right way to wait for a
process to terminate with a timeout. Neither
select nor waitpid seems obvious. I have seen
scripts looking a few times starting with short
intervals and graduately increasing the interval.
-- Kasper Dupont -- der bruger for meget tid paa usenet. For sending spam use mailto:firstname.lastname@example.org /* Would you like fries with that? */