From cf4bc764dcb549cf3fb1df80a1c2f0393f834864 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sun, 10 Sep 2017 22:10:12 -0400 Subject: [PATCH] [mod_cgi] omit cgi_handle_fdevent after proc exit Omit calling cgi_handle_fdevent() after CGI process exit. Another (sub)process may be holding pipe fd open and might write response instead of the initial CGI process. --- src/mod_cgi.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/mod_cgi.c b/src/mod_cgi.c index a611dbcc..d5f7596f 100644 --- a/src/mod_cgi.c +++ b/src/mod_cgi.c @@ -1019,6 +1019,7 @@ static handler_t cgi_waitpid_cb(server *srv, void *p_d, pid_t pid, int status) { if (pid != p->cgi_pid.ptr[i].pid) continue; hctx = (handler_ctx *)p->cgi_pid.ptr[i].ctx; + if (hctx) hctx->pid = -1; cgi_pid_del(p, i); if (WIFEXITED(status)) { @@ -1036,11 +1037,6 @@ static handler_t cgi_waitpid_cb(server *srv, void *p_d, pid_t pid, int status) { "CGI pid", pid, "ended unexpectedly"); } - if (hctx) { - hctx->pid = -1; - cgi_handle_fdevent(srv, hctx, FDEVENT_IN|FDEVENT_HUP); - } - return HANDLER_FINISHED; }