signal, parent & children processes




I did something like:

/* --------------------- */
void sigINT_handler1 (int sig_i)
{
fprintf (stderr, "sigINT_handler1: pid#%d ignores a signal %d\n", getpid(), sig_i);
signal (SIGINT, sigINT_handler1);
}

void sigINT_handler2 (int sig_i)
{
fprintf (stderr, "sigINT_handler2: pid#%d ignores a signal %d\n", getpid(), sig_i);
signal (SIGINT, sigINT_handler2);
}


int main()
// fragments od code
{
sigINT_handler1 (SIGINT);

if (fork() > 0) // Parent
{
// Stuff
waitpid (pid, &status, 0);
}
else // Child
{
sigINT_handler2 (SIGINT);
execvp (<args>);
}
}

Parent catchs SIGINT via sigINT_handler1,
but Child doesn't catch SIGINT via sigINT_handler2.

How can Child catch SIGINT with its own signal handler?


--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn



.



Relevant Pages

  • Re: signal, parent & children processes
    ... > void sigINT_handler1 ... > signal (SIGINT, sigINT_handler1); ... > but Child doesn't catch SIGINT via sigINT_handler2. ...
    (comp.unix.programmer)
  • process group = job, and signal question
    ... void sigint(int signum){ ... int main{ ... signal(SIGINT, sigint); ...
    (comp.os.linux.development.apps)
  • Select in child thread
    ... SIGINT is caught in 'thread_fun'. ... which 'select' should unblock when i raise SIGINT for the first time? ... int thread_select; ...
    (comp.unix.programmer)
  • select, signal, thread
    ... SIGINT is caught in 'thread_fun'. ... which 'select' should unblock when i raise SIGINT for the first time? ... int thread_select; ...
    (comp.unix.programmer)
  • Re: signal, parent & children processes
    ... >> Parent catchs SIGINT via sigINT_handler1, ... >> but Child doesn't catch SIGINT via sigINT_handler2. ... >> How can Child catch SIGINT with its own signal handler? ... > void sigINT_handler1 ...
    (comp.unix.programmer)