… | |
… | |
810 | fd_intern (evpipe [0]); |
810 | fd_intern (evpipe [0]); |
811 | fd_intern (evpipe [1]); |
811 | fd_intern (evpipe [1]); |
812 | |
812 | |
813 | ev_io_set (&pipeev, evpipe [0], EV_READ); |
813 | ev_io_set (&pipeev, evpipe [0], EV_READ); |
814 | ev_io_start (EV_A_ &pipeev); |
814 | ev_io_start (EV_A_ &pipeev); |
815 | ev_unref (EV_A); /* child watcher should not keep loop alive */ |
815 | ev_unref (EV_A); /* watcher should not keep loop alive */ |
816 | } |
816 | } |
817 | } |
817 | } |
818 | |
818 | |
819 | void inline_size |
819 | void inline_size |
820 | evpipe_write (EV_P_ int sig, int async) |
820 | evpipe_write (EV_P_ int sig, int async) |
821 | { |
821 | { |
822 | if (!(gotasync || gotsig)) |
822 | int sent = gotasync || gotsig; |
823 | { |
|
|
824 | int old_errno = errno; |
|
|
825 | |
823 | |
826 | if (sig) gotsig = 1; |
824 | if (sig) gotsig = 1; |
827 | if (async) gotasync = 1; |
825 | if (async) gotasync = 1; |
828 | |
826 | |
|
|
827 | if (!sent) |
|
|
828 | { |
|
|
829 | int old_errno = errno; /* save errno becaue write might clobber it */ |
829 | write (evpipe [1], &old_errno, 1); |
830 | write (evpipe [1], &old_errno, 1); |
830 | errno = old_errno; |
831 | errno = old_errno; |
831 | } |
832 | } |
832 | } |
833 | } |
833 | |
834 | |
… | |
… | |
837 | { |
838 | { |
838 | int dummy; |
839 | int dummy; |
839 | read (evpipe [0], &dummy, 1); |
840 | read (evpipe [0], &dummy, 1); |
840 | } |
841 | } |
841 | |
842 | |
842 | if (gotsig) |
843 | if (gotsig && ev_is_default_loop (EV_A)) |
843 | { |
844 | { |
844 | int signum; |
845 | int signum; |
845 | gotsig = 0; |
846 | gotsig = 0; |
846 | |
847 | |
847 | for (signum = signalmax; signum--; ) |
848 | for (signum = signalmax; signum--; ) |
… | |
… | |
1217 | #endif |
1218 | #endif |
1218 | |
1219 | |
1219 | if (ev_is_active (&pipeev)) |
1220 | if (ev_is_active (&pipeev)) |
1220 | { |
1221 | { |
1221 | /* this "locks" the handlers against writing to the pipe */ |
1222 | /* this "locks" the handlers against writing to the pipe */ |
|
|
1223 | /* while we modify the fd vars */ |
|
|
1224 | gotsig = 1; |
|
|
1225 | #if EV_ASYNC_ENABLE |
1222 | gotsig = gotasync = 1; |
1226 | gotasync = 1; |
|
|
1227 | #endif |
1223 | |
1228 | |
1224 | ev_ref (EV_A); |
1229 | ev_ref (EV_A); |
1225 | ev_io_stop (EV_A_ &pipeev); |
1230 | ev_io_stop (EV_A_ &pipeev); |
1226 | close (evpipe [0]); |
1231 | close (evpipe [0]); |
1227 | close (evpipe [1]); |
1232 | close (evpipe [1]); |