M
Mike
Hi everyone
i am learning advanced C in my spare time, just getting on to the chapter
about child processes. i am really confused about this question!
#include<signal.h>
#include<errno.h>
void handle_sigchld(signo)
int signo;
{
printf("got chld\n");
}
void main(argc, argv)
int argc; char *argv[];
{
struct sigaction myaction;
void bzero();
bzero(&myaction, sizeof myaction);
myaction.sa_handler = handle_sigchld;
sigaction(SIGCHLD, &myaction, 0);
if (!fork()) {
sleep(30);
_exit(0);
}
errno = 0;
waitpid(-1, 0, 0);
switch (errno) {
case 0:
break;
case 3407: /* EINTR */
printf("intr\n");
exit(0);
default:
exit(0);
}
}
when the parent process blocked in 'waitpid',I send it the 'SIGCHLD'
signal by 'kill -s SIGCHLD parentpid', the 'waitpid' returns and sets
'error' to 'EINTR',
when child terminates, the child will also send the parent 'SIGCHLD'
signal, but why doesn't 'waitpid' set errno to 'EINTR'?
thanks in advance!
i am learning advanced C in my spare time, just getting on to the chapter
about child processes. i am really confused about this question!
#include<signal.h>
#include<errno.h>
void handle_sigchld(signo)
int signo;
{
printf("got chld\n");
}
void main(argc, argv)
int argc; char *argv[];
{
struct sigaction myaction;
void bzero();
bzero(&myaction, sizeof myaction);
myaction.sa_handler = handle_sigchld;
sigaction(SIGCHLD, &myaction, 0);
if (!fork()) {
sleep(30);
_exit(0);
}
errno = 0;
waitpid(-1, 0, 0);
switch (errno) {
case 0:
break;
case 3407: /* EINTR */
printf("intr\n");
exit(0);
default:
exit(0);
}
}
when the parent process blocked in 'waitpid',I send it the 'SIGCHLD'
signal by 'kill -s SIGCHLD parentpid', the 'waitpid' returns and sets
'error' to 'EINTR',
when child terminates, the child will also send the parent 'SIGCHLD'
signal, but why doesn't 'waitpid' set errno to 'EINTR'?
thanks in advance!