--- a/src/server/safs/cgi.c Sun Jan 15 18:27:09 2017 +0100 +++ b/src/server/safs/cgi.c Mon Jan 16 14:41:20 2017 +0100 @@ -32,6 +32,10 @@ #include <stdlib.h> #include <unistd.h> +#include <sys/types.h> +#include <signal.h> +#include <sys/wait.h> + #include "../util/util.h" #include "../util/pblock.h" #include "../../ucx/string.h" @@ -100,6 +104,7 @@ r = netbuf_getbytes(sn->inbuf, buf, 4096); if(r <= 0) { // TODO: handleerror + kill(cgip.pid, SIGTERM); cgi_close(&cgip); return REQ_ABORTED; } @@ -148,7 +153,7 @@ } } - cgi_close(&cgip); + cgi_close(&cgip); // TODO: check return value cgi_parser_free(parser); return result; @@ -209,7 +214,10 @@ return REQ_PROCEED; } -void cgi_close(CGIProcess *p) { +int cgi_close(CGIProcess *p) { + int status = -1; + waitpid(p->pid, &status, 0); + if(p->in[0] != -1) { close(p->in[0]); } @@ -222,6 +230,8 @@ if(p->out[1] != -1) { close(p->out[1]); } + + return 0; } CGIResponseParser* cgi_parser_new(Session *sn, Request *rq) {