I have a parent process that at some point forks into at least one child process.
I want to kill everything (parent+children) if the parent or any of its child processes get a SIGINT or SIGTERM.
How can I do this?
I know I have to use stuff from signal.h and probably a mutex(not sure on this?) to flag when it's time to die.
I would appreciate if you guys could help me.
Thank you.
Anon.
Name:
Anonymous2009-11-19 6:05
set up a signal handler which catches SIGINT and SIGTERM and then uses killpg(0, SIGKILL);.
something like: void handler(int signal)
{
killpg(0, SIGKILL);
}
i haven't tested it, but i'm pretty sure it'll work.
Name:
Anonymous2009-11-19 6:21
Suck on my cheesy noise badger
Name:
Anonymous2009-11-19 7:27
>>2
Do I have to set the handler in the begging of the parents' main and then in the begging of the child (right after the fork made in the parent)?
Much thankful for the assistance!
Name:
Anonymous2009-11-19 7:29
>>4
should be inherited by the children if you set it before the fork()'s