… | |
… | |
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 | /*****************************************************************************/ |
… | |
… | |
1761 | |
1765 | |
1762 | # ifdef _WIN32 |
1766 | # ifdef _WIN32 |
1763 | # define lstat(a,b) stat(a,b) |
1767 | # define lstat(a,b) stat(a,b) |
1764 | # endif |
1768 | # endif |
1765 | |
1769 | |
|
|
1770 | #define DEF_STAT_INTERVAL 5.0074891 |
|
|
1771 | #define MIN_STAT_INTERVAL 0.1074891 |
|
|
1772 | |
1766 | void |
1773 | void |
1767 | ev_stat_stat (EV_P_ ev_stat *w) |
1774 | ev_stat_stat (EV_P_ ev_stat *w) |
1768 | { |
1775 | { |
1769 | if (lstat (w->path, &w->attr) < 0) |
1776 | if (lstat (w->path, &w->attr) < 0) |
1770 | w->attr.st_nlink = 0; |
1777 | w->attr.st_nlink = 0; |
… | |
… | |
1795 | /* since we use memcmp, we need to clear any padding data etc. */ |
1802 | /* since we use memcmp, we need to clear any padding data etc. */ |
1796 | memset (&w->prev, 0, sizeof (ev_statdata)); |
1803 | memset (&w->prev, 0, sizeof (ev_statdata)); |
1797 | memset (&w->attr, 0, sizeof (ev_statdata)); |
1804 | memset (&w->attr, 0, sizeof (ev_statdata)); |
1798 | |
1805 | |
1799 | ev_stat_stat (EV_A_ w); |
1806 | ev_stat_stat (EV_A_ w); |
|
|
1807 | |
|
|
1808 | if (w->interval < MIN_STAT_INTERVAL) |
|
|
1809 | w->interval = w->interval ? MIN_STAT_INTERVAL : DEF_STAT_INTERVAL; |
1800 | |
1810 | |
1801 | ev_timer_init (&w->timer, stat_timer_cb, w->interval, w->interval); |
1811 | ev_timer_init (&w->timer, stat_timer_cb, w->interval, w->interval); |
1802 | ev_set_priority (&w->timer, ev_priority (w)); |
1812 | ev_set_priority (&w->timer, ev_priority (w)); |
1803 | ev_timer_start (EV_A_ &w->timer); |
1813 | ev_timer_start (EV_A_ &w->timer); |
1804 | |
1814 | |