uhttpd: properly initialize sigaction, restore SIGTERM for childs
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 21 Mar 2010 20:52:41 +0000 (20:52 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 21 Mar 2010 20:52:41 +0000 (20:52 +0000)
contrib/package/uhttpd/src/uhttpd-cgi.c
contrib/package/uhttpd/src/uhttpd-lua.c
contrib/package/uhttpd/src/uhttpd.c

index a239c8bc992ae30a0930defdfd93f89c7d20da16..5565197ca7e576a2b1bf6b2069fa19a95172d494 100644 (file)
@@ -155,6 +155,7 @@ void uh_cgi_request(struct client *cl, struct http_request *req, struct path_inf
        fd_set reader;
        fd_set writer;
 
+       struct sigaction sa;
        struct timeval timeout;
        struct http_response *res;
 
@@ -184,7 +185,13 @@ void uh_cgi_request(struct client *cl, struct http_request *req, struct path_inf
 
                /* exec child */
                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(wfd[1]);
 
index 1334aeeb41ff824a43955154fb644f7cf7712c04..db14eda450114bcac82377931c066bfd45f66aa5 100644 (file)
@@ -229,6 +229,7 @@ void uh_lua_request(struct client *cl, struct http_request *req, lua_State *L)
        fd_set reader;
        fd_set writer;
 
+       struct sigaction sa;
        struct timeval timeout;
 
 
@@ -255,7 +256,13 @@ void uh_lua_request(struct client *cl, struct http_request *req, lua_State *L)
                        break;
 
                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(wfd[1]);
 
index ea4ca00c0aa45e2bcd26ad048fdb8d785a13b478..401749faee05945e0212d3ff4e45e2dbe3600ce8 100644 (file)
@@ -423,6 +423,9 @@ int main (int argc, char **argv)
        FD_ZERO(&read_fds);
 
        /* handle SIGPIPE, SIGCHILD */
+       sa.sa_flags = 0;
+       sigemptyset(&sa.sa_mask);
+
        sa.sa_handler = SIG_IGN;
        sigaction(SIGPIPE, &sa, NULL);
        sigaction(SIGCHLD, &sa, NULL);