… | |
… | |
715 | |
715 | |
716 | #ifndef _WIN32 |
716 | #ifndef _WIN32 |
717 | |
717 | |
718 | static ev_signal childev; |
718 | static ev_signal childev; |
719 | |
719 | |
720 | #ifndef WCONTINUED |
|
|
721 | # define WCONTINUED 0 |
|
|
722 | #endif |
|
|
723 | |
|
|
724 | void inline_speed |
720 | void inline_speed |
725 | child_reap (EV_P_ ev_signal *sw, int chain, int pid, int status) |
721 | child_reap (EV_P_ ev_signal *sw, int chain, int pid, int status) |
726 | { |
722 | { |
727 | ev_child *w; |
723 | ev_child *w; |
728 | |
724 | |
… | |
… | |
734 | w->rstatus = status; |
730 | w->rstatus = status; |
735 | ev_feed_event (EV_A_ (W)w, EV_CHILD); |
731 | ev_feed_event (EV_A_ (W)w, EV_CHILD); |
736 | } |
732 | } |
737 | } |
733 | } |
738 | |
734 | |
|
|
735 | #ifndef WCONTINUED |
|
|
736 | # define WCONTINUED 0 |
|
|
737 | #endif |
|
|
738 | |
739 | static void |
739 | static void |
740 | childcb (EV_P_ ev_signal *sw, int revents) |
740 | childcb (EV_P_ ev_signal *sw, int revents) |
741 | { |
741 | { |
742 | int pid, status; |
742 | int pid, status; |
743 | |
743 | |
|
|
744 | /* some systems define WCONTINUED but then fail to support it (linux 2.4) */ |
744 | if (0 < (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED))) |
745 | if (0 >= (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED))) |
745 | { |
746 | if (!WCONTINUED |
|
|
747 | || errno != EINVAL |
|
|
748 | || 0 >= (pid = waitpid (-1, &status, WNOHANG | WUNTRACED))) |
|
|
749 | return; |
|
|
750 | |
746 | /* make sure we are called again until all childs have been reaped */ |
751 | /* make sure we are called again until all childs have been reaped */ |
747 | /* we need to do it this way so that the callback gets called before we continue */ |
752 | /* we need to do it this way so that the callback gets called before we continue */ |
748 | ev_feed_event (EV_A_ (W)sw, EV_SIGNAL); |
753 | ev_feed_event (EV_A_ (W)sw, EV_SIGNAL); |
749 | |
754 | |
750 | child_reap (EV_A_ sw, pid, pid, status); |
755 | child_reap (EV_A_ sw, pid, pid, status); |
751 | child_reap (EV_A_ sw, 0, pid, status); /* this might trigger a watcher twice, but feed_event catches that */ |
756 | child_reap (EV_A_ sw, 0, pid, status); /* this might trigger a watcher twice, but feed_event catches that */ |
752 | } |
|
|
753 | } |
757 | } |
754 | |
758 | |
755 | #endif |
759 | #endif |
756 | |
760 | |
757 | /*****************************************************************************/ |
761 | /*****************************************************************************/ |