Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

[C/POSIX] kill + signal

Name: Anonymous 2010-12-08 7:48

I need to make something in a way that when a program receives a SIGINT/SIGTERM all the processes in this program's process group that receives this signal get killed.

Will the following work?


//shit done in the main:
pid = fork();
signal(SIGINT, (__sighandler_t) murder);
signal(SIGTERM, (__sighandler_t) murder);
//moreblabla
void murder(void)
{
 lol(); // frees shared memory and semaphores;
 kill(0, 9);
}


Some guys told me that this should suffice, and that I should also consider substituting signal for sigaction.

What do you think?

Name: Anonymous 2010-12-08 11:08

OP and 3 here:
How would I use (int sig) in handler?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List