pid_t pid = fork();
if (0 == pid) // child process
{
execvp ...;
}
I send a signal (such as SIGINT) to the parent process, the child process receive the signal as well as the parent process.
However I don't want to child process to receive the signal when I send the parent process a signal. And the child process has its only signal hanlder to handle a signal such as SIGINT.
How can I do? I've googled, no answer so far.
Waiting online!!! Thanks in advance!!!
Yeah, you're right. My problem has solved. Thanks!
I'm not so familiar with unix/linux. At first, I waited a long time for the answer. No body answers or knowns, then I posted the question in another famous forum in my country, I got the the same answer with yours. Thanks any way.
The first child process will still be alive when the parent process kills itself.
(ps: threre are serval errors in your program, but no big deal, I got you)
Thanks Jackliang..
Can you please verify if the below comments are correct for
the above program :
"The statement setpgrp(); parents sets a separate group
number. Then the group of statements within the for loop
will create 20 Childs using fork() statement.
One set of Childs(10 childs will be created by the first if
statement And the Childs created by this if statement will
create their own Group and will be paused until receives any
signal by some other Process to resume the execution.
And the other set of Childs(10 Childs) will be created by the
second if statement and all the childs created by the second
if statement will also be paused to until receives any signal
by some other Process to resume the execution.
The statement kill(0, SIGINT); the parent process will send
the kill signal to all the Child processes belongs to the same
group as parent, hence the Childs created by the first if
statement would remain as it is as don�t have the same
group as parent process and the Childs created by the
second if statement will be terminated on receiving this kill
signal."