X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/secnet/blobdiff_plain/794f2398b8fe84bf398bb10d6eeca6fe6737f65f..4f5e39ecfaa49376b0a5c3a4c384e91a828c1105:/process.c?ds=inline diff --git a/process.c b/process.c index 8e464be..f2a2e42 100644 --- a/process.c +++ b/process.c @@ -68,7 +68,7 @@ pid_t makesubproc(process_entry_fn *entry, process_callback_fn *cb, c->cst=cst; if (!signal_handling) { - fatal("makesubproc called before signal handling started\n"); + fatal("makesubproc called before signal handling started"); } p=fork(); if (p==0) { @@ -234,11 +234,21 @@ static void set_default_signals(void) static void signal_handler(int signum) { + int saved_errno; uint8_t thing=0; sigaddset(&pending,signum); + /* XXX the write() may set errno, which can make the main program fail. + However, signal handlers aren't allowed to modify anything which + is not of type sig_atomic_t. The world is broken. */ + /* I have decided to save and restore errno anyway; on most + architectures on which secnet can run modifications to errno + will be atomic, and it seems to be the lesser of the two + evils. */ + saved_errno=errno; write(spw,&thing,1); /* We don't care if this fails (i.e. the pipe is full) because the service routine will spot the pending signal anyway */ + errno=saved_errno; } static void register_signal_handler(struct signotify *s)