+static void
+sighandler (int signum)
+{
+ signals [signum - 1].gotsig = 1;
+
+ if (!gotsig)
+ {
+ gotsig = 1;
+ write (sigpipe [1], &gotsig, 1);
+ }
+}
+
+static void
+sigcb (struct ev_io *iow, int revents)
+{
+ struct ev_signal *w;
+ int sig;
+
+ gotsig = 0;
+ read (sigpipe [0], &revents, 1);
+
+ for (sig = signalmax; sig--; )
+ if (signals [sig].gotsig)
+ {
+ signals [sig].gotsig = 0;
+
+ for (w = signals [sig].head; w; w = w->next)
+ event ((W)w, EV_SIGNAL);
+ }
+}
+
+static void
+siginit (void)
+{
+ fcntl (sigpipe [0], F_SETFD, FD_CLOEXEC);
+ fcntl (sigpipe [1], F_SETFD, FD_CLOEXEC);
+
+ /* rather than sort out wether we really need nb, set it */
+ fcntl (sigpipe [0], F_SETFL, O_NONBLOCK);
+ fcntl (sigpipe [1], F_SETFL, O_NONBLOCK);
+
+ evio_set (&sigev, sigpipe [0], EV_READ);
+ evio_start (&sigev);
+}
+
+/*****************************************************************************/
+
+static struct ev_idle **idles;
+static int idlemax, idlecnt;
+
+static struct ev_check **checks;
+static int checkmax, checkcnt;
+
+/*****************************************************************************/
+