据我了解,发送给父进程的信号不应发送给子进程。那么在下面的示例中,为什么 SIGINT 会同时到达孩子和父母?
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
void sigCatcher( int );
int main ( void ) {
if (signal(SIGINT, sigCatcher) == SIG_ERR) {
fprintf(stderr, "Couldn't register signal handler\n");
exit(1);
}
if(fork() == 0) {
char *argv[] = {"find","/",".",NULL};
execvp("find",argv);
}
for (;;) {
sleep(10);
write(STDOUT_FILENO, "W\n",3);
}
return 0;
}
void sigCatcher( int theSignal ) {
write(STDOUT_FILENO, "C\n",3);
}