extern struct event_list signalqueue;
-static short evsigcaught[NSIG];
+static sig_atomic_t evsigcaught[NSIG];
static int needrecalc;
volatile sig_atomic_t evsignal_caught = 0;
static int ev_signal_added;
/* Callback for when the signal handler write a byte to our signaling socket */
-static void evsignal_cb(int fd, short what, void *arg)
+static void
+evsignal_cb(int fd, short what, void *arg)
{
static char signals[100];
struct event *ev = arg;
- int n;
+ ssize_t n;
n = read(fd, signals, sizeof(signals));
if (n == -1)
FD_CLOSEONEXEC(ev_signal_pair[0]);
FD_CLOSEONEXEC(ev_signal_pair[1]);
+ fcntl(ev_signal_pair[0], F_SETFL, O_NONBLOCK);
+
event_set(&ev_signal, ev_signal_pair[1], EV_READ,
evsignal_cb, &ev_signal);
ev_signal.ev_flags |= EVLIST_INTERNAL;
static void
evsignal_handler(int sig)
{
+ int save_errno = errno;
+
evsigcaught[sig]++;
evsignal_caught = 1;
/* Wake up our notification mechanism */
write(ev_signal_pair[0], "a", 1);
+ errno = save_errno;
}
int
evsignal_process(void)
{
struct event *ev;
- short ncalls;
+ sig_atomic_t ncalls;
TAILQ_FOREACH(ev, &signalqueue, ev_signal_next) {
ncalls = evsigcaught[EVENT_SIGNAL(ev)];