Commit eff3fbb6 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(use_sa_restart): New static variable.

(sig_on_signal): Add SA_RESTART if appropriate.
(oop_signal_new): Don't just blindly set FD_CLOEXEC and
	O_NONBLOCK.  Read the old settings first.
(oop_signal_use_sa_restart): New function.
parent 63e5cf98
......@@ -35,6 +35,7 @@ struct oop_adapter_signal {
};
static struct oop_adapter_signal *sig_owner[OOP_NUM_SIGNALS];
static int use_sa_restart = 0;
static oop_adapter_signal *verify_source(oop_source *source) {
oop_adapter_signal * const s = (oop_adapter_signal *) source;
......@@ -137,6 +138,7 @@ static void sig_on_signal(oop_source *source,int sig,
#ifdef SA_NODEFER
act.sa_flags &= ~SA_NODEFER;
#endif
if (use_sa_restart) act.sa_flags |= SA_RESTART;
sigaction(sig,&act,NULL);
}
}
......@@ -169,6 +171,7 @@ static void sig_cancel_signal(oop_source *source,int sig,
oop_adapter_signal *oop_signal_new(oop_source *source) {
int i;
int flags;
oop_adapter_signal * const s = oop_malloc(sizeof(*s));
if (NULL == s) return NULL;
assert(NULL != source);
......@@ -177,10 +180,14 @@ oop_adapter_signal *oop_signal_new(oop_source *source) {
return NULL;
}
fcntl(s->pipefd[0],F_SETFD,FD_CLOEXEC);
fcntl(s->pipefd[1],F_SETFD,FD_CLOEXEC);
fcntl(s->pipefd[0],F_SETFL,O_NONBLOCK);
fcntl(s->pipefd[1],F_SETFL,O_NONBLOCK);
flags = fcntl(s->pipefd[0],F_GETFD,0);
fcntl(s->pipefd[0],F_SETFD,flags|FD_CLOEXEC);
flags = fcntl(s->pipefd[1],F_GETFD,0);
fcntl(s->pipefd[1],F_SETFD,flags|FD_CLOEXEC);
flags = fcntl(s->pipefd[0],F_GETFL,0);
fcntl(s->pipefd[0],F_SETFL,flags|O_NONBLOCK);
flags = fcntl(s->pipefd[1],F_GETFL,0);
fcntl(s->pipefd[1],F_SETFL,flags|O_NONBLOCK);
s->oop.on_fd = sig_on_fd;
s->oop.cancel_fd = sig_cancel_fd;
......@@ -215,3 +222,10 @@ void oop_signal_delete(oop_adapter_signal *s) {
oop_source *oop_signal_source(oop_adapter_signal *s) {
return &s->oop;
}
void oop_signal_use_sa_restart(void) {
int i;
for (i = 0; i < OOP_NUM_SIGNALS; ++i)
assert(NULL == sig_owner[i] && "signal handler already registered");
use_sa_restart = 1;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment