diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2010-03-21 20:06:50 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2010-03-21 20:06:50 +0000 |
commit | fa712a0bc9ac90b2172877dc9835c38945838b39 (patch) | |
tree | 3cd262e575937d8da7adcdea600d638904a34508 /contrib/package/uhttpd | |
parent | d87fefbda608d1bbf296cc7fbb766e72b8b94c13 (diff) |
uhttpd: deliver SIGTERM to child when parent leaves I/O loop
Diffstat (limited to 'contrib/package/uhttpd')
-rw-r--r-- | contrib/package/uhttpd/src/uhttpd-cgi.c | 7 | ||||
-rw-r--r-- | contrib/package/uhttpd/src/uhttpd-lua.c | 9 |
2 files changed, 12 insertions, 4 deletions
diff --git a/contrib/package/uhttpd/src/uhttpd-cgi.c b/contrib/package/uhttpd/src/uhttpd-cgi.c index a6e5d99e07..a239c8bc99 100644 --- a/contrib/package/uhttpd/src/uhttpd-cgi.c +++ b/contrib/package/uhttpd/src/uhttpd-cgi.c @@ -150,6 +150,8 @@ void uh_cgi_request(struct client *cl, struct http_request *req, struct path_inf char buf[UH_LIMIT_MSGHEAD]; char hdr[UH_LIMIT_MSGHEAD]; + pid_t child; + fd_set reader; fd_set writer; @@ -172,7 +174,7 @@ void uh_cgi_request(struct client *cl, struct http_request *req, struct path_inf } /* fork off child process */ - switch( fork() ) + switch( (child = fork()) ) { /* oops */ case -1: @@ -543,6 +545,9 @@ void uh_cgi_request(struct client *cl, struct http_request *req, struct path_inf close(rfd[0]); close(wfd[1]); + if( !kill(child, 0) ) + kill(child, SIGTERM); + break; } } diff --git a/contrib/package/uhttpd/src/uhttpd-lua.c b/contrib/package/uhttpd/src/uhttpd-lua.c index e88c42e444..1334aeeb41 100644 --- a/contrib/package/uhttpd/src/uhttpd-lua.c +++ b/contrib/package/uhttpd/src/uhttpd-lua.c @@ -211,8 +211,6 @@ lua_State * uh_lua_init(const char *handler) void uh_lua_request(struct client *cl, struct http_request *req, lua_State *L) { - pid_t pid; - int i, data_sent; int content_length = 0; int buflen = 0; @@ -226,6 +224,8 @@ void uh_lua_request(struct client *cl, struct http_request *req, lua_State *L) char buf[UH_LIMIT_MSGHEAD]; + pid_t child; + fd_set reader; fd_set writer; @@ -247,7 +247,7 @@ void uh_lua_request(struct client *cl, struct http_request *req, lua_State *L) } - switch( (pid = fork()) ) + switch( (child = fork()) ) { case -1: uh_http_sendhf(cl, 500, "Internal Server Error", @@ -519,6 +519,9 @@ void uh_lua_request(struct client *cl, struct http_request *req, lua_State *L) close(rfd[0]); close(wfd[1]); + if( !kill(child, 0) ) + kill(child, SIGTERM); + break; } } |