… | |
… | |
47 | #include <sys/wait.h> |
47 | #include <sys/wait.h> |
48 | #include <sys/time.h> |
48 | #include <sys/time.h> |
49 | #include <time.h> |
49 | #include <time.h> |
50 | |
50 | |
51 | #ifndef EV_USE_MONOTONIC |
51 | #ifndef EV_USE_MONOTONIC |
52 | # ifdef CLOCK_MONOTONIC |
|
|
53 | # define EV_USE_MONOTONIC 1 |
52 | # define EV_USE_MONOTONIC 1 |
54 | # endif |
53 | #endif |
|
|
54 | |
|
|
55 | #ifndef CLOCK_MONOTONIC |
|
|
56 | # undef EV_USE_MONOTONIC |
|
|
57 | # define EV_USE_MONOTONIC 0 |
55 | #endif |
58 | #endif |
56 | |
59 | |
57 | #ifndef EV_USE_SELECT |
60 | #ifndef EV_USE_SELECT |
58 | # define EV_USE_SELECT 1 |
61 | # define EV_USE_SELECT 1 |
59 | #endif |
62 | #endif |
… | |
… | |
363 | |
366 | |
364 | static void |
367 | static void |
365 | sigcb (struct ev_io *iow, int revents) |
368 | sigcb (struct ev_io *iow, int revents) |
366 | { |
369 | { |
367 | struct ev_signal *w; |
370 | struct ev_signal *w; |
368 | int sig; |
371 | int signum; |
369 | |
372 | |
370 | read (sigpipe [0], &revents, 1); |
373 | read (sigpipe [0], &revents, 1); |
371 | gotsig = 0; |
374 | gotsig = 0; |
372 | |
375 | |
373 | for (sig = signalmax; sig--; ) |
376 | for (signum = signalmax; signum--; ) |
374 | if (signals [sig].gotsig) |
377 | if (signals [signum].gotsig) |
375 | { |
378 | { |
376 | signals [sig].gotsig = 0; |
379 | signals [signum].gotsig = 0; |
377 | |
380 | |
378 | for (w = signals [sig].head; w; w = w->next) |
381 | for (w = signals [signum].head; w; w = w->next) |
379 | event ((W)w, EV_SIGNAL); |
382 | event ((W)w, EV_SIGNAL); |
380 | } |
383 | } |
381 | } |
384 | } |
382 | |
385 | |
383 | static void |
386 | static void |
… | |
… | |
420 | struct ev_child *w; |
423 | struct ev_child *w; |
421 | int pid, status; |
424 | int pid, status; |
422 | |
425 | |
423 | while ((pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED)) != -1) |
426 | while ((pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED)) != -1) |
424 | for (w = childs [pid & (PID_HASHSIZE - 1)]; w; w = w->next) |
427 | for (w = childs [pid & (PID_HASHSIZE - 1)]; w; w = w->next) |
425 | if (w->pid == pid || w->pid == -1) |
428 | if (w->pid == pid || !w->pid) |
426 | { |
429 | { |
427 | w->status = status; |
430 | w->status = status; |
428 | event ((W)w, EV_CHILD); |
431 | event ((W)w, EV_CHILD); |
429 | } |
432 | } |
430 | } |
433 | } |
… | |
… | |
763 | /*****************************************************************************/ |
766 | /*****************************************************************************/ |
764 | |
767 | |
765 | void |
768 | void |
766 | ev_io_start (struct ev_io *w) |
769 | ev_io_start (struct ev_io *w) |
767 | { |
770 | { |
768 | if (ev_is_active (w)) |
|
|
769 | return; |
|
|
770 | |
|
|
771 | int fd = w->fd; |
771 | int fd = w->fd; |
|
|
772 | |
|
|
773 | if (ev_is_active (w)) |
|
|
774 | return; |
772 | |
775 | |
773 | assert (("ev_io_start called with negative fd", fd >= 0)); |
776 | assert (("ev_io_start called with negative fd", fd >= 0)); |
774 | |
777 | |
775 | ev_start ((W)w, 1); |
778 | ev_start ((W)w, 1); |
776 | array_needsize (anfds, anfdmax, fd + 1, anfds_init); |
779 | array_needsize (anfds, anfdmax, fd + 1, anfds_init); |