diff --git a/NEWS b/NEWS index 805c797f..1d0642af 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,7 @@ NEWS * cmake: Fix crypt lib check * cmake: Add -export-dynamic to link flags, fixes build on FreeBSD * Set FD_CLOEXEC for bound sockets before pipe-logger forks (fixes #2026) + * Reset ignored signals to SIG_DFL before exec() in fastcgi/scgi (fixes #2029) - 1.4.23 - 2009-06-19 * Added some extra warning options in cmake and fix the resulting warnings (unused/static functions) diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c index c18b059c..d42abf20 100644 --- a/src/mod_fastcgi.c +++ b/src/mod_fastcgi.c @@ -384,6 +384,21 @@ typedef struct { /* ok, we need a prototype */ static handler_t fcgi_handle_fdevent(void *s, void *ctx, int revents); +static void reset_signals(void) { +#ifdef SIGTTOU + signal(SIGTTOU, SIG_DFL); +#endif +#ifdef SIGTTIN + signal(SIGTTIN, SIG_DFL); +#endif +#ifdef SIGTSTP + signal(SIGTSTP, SIG_DFL); +#endif + signal(SIGHUP, SIG_DFL); + signal(SIGPIPE, SIG_DFL); + signal(SIGUSR1, SIG_DFL); +} + static void fastcgi_status_copy_procname(buffer *b, fcgi_extension_host *host, fcgi_proc *proc) { buffer_copy_string_len(b, CONST_STR_LEN("fastcgi.backend.")); buffer_append_string_buffer(b, host->id); @@ -1052,6 +1067,7 @@ static int fcgi_spawn_connection(server *srv, *c = '/'; } + reset_signals(); /* exec the cgi */ execve(arg.ptr[0], arg.ptr, env.ptr); diff --git a/src/mod_scgi.c b/src/mod_scgi.c index 8f356ff9..9d8c4125 100644 --- a/src/mod_scgi.c +++ b/src/mod_scgi.c @@ -331,7 +331,20 @@ static handler_t scgi_handle_fdevent(void *s, void *ctx, int revents); int scgi_proclist_sort_down(server *srv, scgi_extension_host *host, scgi_proc *proc); - +static void reset_signals(void) { +#ifdef SIGTTOU + signal(SIGTTOU, SIG_DFL); +#endif +#ifdef SIGTTIN + signal(SIGTTIN, SIG_DFL); +#endif +#ifdef SIGTSTP + signal(SIGTSTP, SIG_DFL); +#endif + signal(SIGHUP, SIG_DFL); + signal(SIGPIPE, SIG_DFL); + signal(SIGUSR1, SIG_DFL); +} static handler_ctx * handler_ctx_init() { handler_ctx * hctx; @@ -826,6 +839,8 @@ static int scgi_spawn_connection(server *srv, buffer_copy_string_len(b, CONST_STR_LEN("exec ")); buffer_append_string_buffer(b, host->bin_path); + reset_signals(); + /* exec the cgi */ execle("/bin/sh", "sh", "-c", b->ptr, (char *)NULL, env.ptr);