uhttpd: properly initialize sigaction, restore SIGTERM for childs

This commit is contained in:
Jo-Philipp Wich 2010-03-21 20:52:41 +00:00
parent fa712a0bc9
commit d817ebf007
3 changed files with 19 additions and 2 deletions

View file

@ -155,6 +155,7 @@ void uh_cgi_request(struct client *cl, struct http_request *req, struct path_inf
fd_set reader; fd_set reader;
fd_set writer; fd_set writer;
struct sigaction sa;
struct timeval timeout; struct timeval timeout;
struct http_response *res; struct http_response *res;
@ -184,7 +185,13 @@ void uh_cgi_request(struct client *cl, struct http_request *req, struct path_inf
/* exec child */ /* exec child */
case 0: case 0:
/* child */ /* restore SIGTERM */
sa.sa_flags = 0;
sa.sa_handler = SIG_DFL;
sigemptyset(&sa.sa_mask);
sigaction(SIGTERM, &sa, NULL);
/* close loose pipe ends */
close(rfd[0]); close(rfd[0]);
close(wfd[1]); close(wfd[1]);

View file

@ -229,6 +229,7 @@ void uh_lua_request(struct client *cl, struct http_request *req, lua_State *L)
fd_set reader; fd_set reader;
fd_set writer; fd_set writer;
struct sigaction sa;
struct timeval timeout; struct timeval timeout;
@ -255,7 +256,13 @@ void uh_lua_request(struct client *cl, struct http_request *req, lua_State *L)
break; break;
case 0: case 0:
/* child */ /* restore SIGTERM */
sa.sa_flags = 0;
sa.sa_handler = SIG_DFL;
sigemptyset(&sa.sa_mask);
sigaction(SIGTERM, &sa, NULL);
/* close loose pipe ends */
close(rfd[0]); close(rfd[0]);
close(wfd[1]); close(wfd[1]);

View file

@ -423,6 +423,9 @@ int main (int argc, char **argv)
FD_ZERO(&read_fds); FD_ZERO(&read_fds);
/* handle SIGPIPE, SIGCHILD */ /* handle SIGPIPE, SIGCHILD */
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sa.sa_handler = SIG_IGN; sa.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sa, NULL); sigaction(SIGPIPE, &sa, NULL);
sigaction(SIGCHLD, &sa, NULL); sigaction(SIGCHLD, &sa, NULL);