views:

22

answers:

1

I am writing a daemon in c++ on linux which would launch many processes. I'm considering a scenario when the daemon itself is killed. On restarting the daemon, I would like to kill all other processes launched by this daemon. Ideally I would like all the processes created by this daemon to die if it is killed. I'm considering a scenario when daemon dies after creating the process and without writing onto the log file.

I was wondering if I could use /proc/proc_id/ kind of directories. But in this case I would like these directories to be created somewhere in my home directory. So, that I just scan them and kill these processes. Is it possible ? Or if there is any other solution.

Note: I do not have the access to the source code of any of the child process.

+2  A: 

From the kill(2) man page:

   If pid is less than -1, then sig is sent to every process in  the  pro-
   cess group whose ID is -pid.
Ignacio Vazquez-Abrams