+void
+ev_child_start (struct ev_child *w)
+{
+ if (ev_is_active (w))
+ return;
+
+ ev_start ((W)w, 1);
+ wlist_add ((WL *)&childs [w->pid & (PID_HASHSIZE - 1)], (WL)w);
+}
+
+void
+ev_child_stop (struct ev_child *w)
+{
+ ev_clear_pending ((W)w);
+ if (ev_is_active (w))
+ return;
+
+ wlist_del ((WL *)&childs [w->pid & (PID_HASHSIZE - 1)], (WL)w);
+ ev_stop ((W)w);
+}
+
+/*****************************************************************************/
+
+struct ev_once
+{
+ struct ev_io io;
+ struct ev_timer to;
+ void (*cb)(int revents, void *arg);
+ void *arg;
+};
+
+static void
+once_cb (struct ev_once *once, int revents)
+{
+ void (*cb)(int revents, void *arg) = once->cb;
+ void *arg = once->arg;
+
+ ev_io_stop (&once->io);
+ ev_timer_stop (&once->to);
+ free (once);
+
+ cb (revents, arg);
+}
+
+static void
+once_cb_io (struct ev_io *w, int revents)
+{
+ once_cb ((struct ev_once *)(((char *)w) - offsetof (struct ev_once, io)), revents);
+}
+
+static void
+once_cb_to (struct ev_timer *w, int revents)
+{
+ once_cb ((struct ev_once *)(((char *)w) - offsetof (struct ev_once, to)), revents);
+}
+
+void
+ev_once (int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg)
+{
+ struct ev_once *once = malloc (sizeof (struct ev_once));
+
+ if (!once)
+ cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg);
+ else
+ {
+ once->cb = cb;
+ once->arg = arg;
+
+ ev_watcher_init (&once->io, once_cb_io);
+ if (fd >= 0)
+ {
+ ev_io_set (&once->io, fd, events);
+ ev_io_start (&once->io);
+ }
+
+ ev_watcher_init (&once->to, once_cb_to);
+ if (timeout >= 0.)
+ {
+ ev_timer_set (&once->to, timeout, 0.);
+ ev_timer_start (&once->to);
+ }
+ }
+}
+