Running scripts should now exit as expected. - geomyidae - A small C-based gopherd.
HTML git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
DIR commit 9556d3960086cdf6365a612823915fd6a9906bac
DIR parent 0bbe73dae350eaa6ae6cf712d91b90c9ae760c53
HTML Author: Christoph Lohmann <20h@r-36.net>
Date: Mon, 7 Mar 2011 22:01:11 +0100
Running scripts should now exit as expected.
Diffstat:
M handlr.c | 13 ++++++++++++-
M main.c | 1 +
2 files changed, 13 insertions(+), 1 deletion(-)
---
DIR diff --git a/handlr.c b/handlr.c
@@ -15,6 +15,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
+#include <sys/wait.h>
#include "ind.h"
#include "arg.h"
@@ -177,6 +178,16 @@ handlecgi(int sock, char *file, char *port, char *base, char *args,
if(sear == nil)
sear = "";
- execl(file, p, sear, args, (char *)nil);
+ switch(fork()) {
+ case 0:
+ execl(file, p, sear, args, (char *)nil);
+ case -1:
+ break;
+ default:
+ wait(NULL);
+ shutdown(sock, SHUT_RDWR);
+ close(sock);
+ break;
+ }
}
DIR diff --git a/main.c b/main.c
@@ -212,6 +212,7 @@ sighandler(int sig)
case SIGQUIT:
case SIGABRT:
case SIGTERM:
+ case SIGKILL:
if(logfile != nil)
stoplogging(glfd);
if(listfd >= 0)