+ if (expect_false (!ev_is_active (w)))
+ return;
+
+ checks [((W)w)->active - 1] = checks [--checkcnt];
+ ev_stop (EV_A_ (W)w);
+}
+
+#ifndef SA_RESTART
+# define SA_RESTART 0
+#endif
+
+void
+ev_signal_start (EV_P_ struct ev_signal *w)
+{
+#if EV_MULTIPLICITY
+ assert (("signal watchers are only supported in the default loop", loop == ev_default_loop_ptr));
+#endif
+ if (expect_false (ev_is_active (w)))
+ return;
+
+ assert (("ev_signal_start called with illegal signal number", w->signum > 0));
+
+ ev_start (EV_A_ (W)w, 1);
+ array_needsize (ANSIG, signals, signalmax, w->signum, signals_init);
+ wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w);
+
+ if (!((WL)w)->next)
+ {
+#if _WIN32
+ signal (w->signum, sighandler);
+#else
+ struct sigaction sa;
+ sa.sa_handler = sighandler;
+ sigfillset (&sa.sa_mask);
+ sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */
+ sigaction (w->signum, &sa, 0);
+#endif
+ }
+}
+
+void
+ev_signal_stop (EV_P_ struct ev_signal *w)
+{
+ ev_clear_pending (EV_A_ (W)w);
+ if (expect_false (!ev_is_active (w)))