I create a sigset_t
and set it empty, then add SIGCHLD
to it, then set it BLOCK
:
sigset_t sigmask;
sigemptyset (&sigmask);
sigprocmask (SIG_BLOCK, &sigmask, NULL);
Then create a signalfd
via signalfd4()
int signalfd = signalfd4 (-1, &sigmask, sizeof(sigset_t), SFD_NONBLOCK);
Then add it to a epollfd which created previously:
struct epoll_event epev;
memset (&epev, 0, sizeof(struct epoll_event));
epev.events = POLLIN;
int retval = epoll_ctl (epollfd, EPOLL_CTL_ADD, signalfd, &epev);
and retval is 0;
At last, I use epoll_wait(epollfd, ...)
to wait my child process which careate by fork() and sleep 2 senconds without do anything then exit, but nothing returned.
Anyone please give me some help on this? Thank you!