X-Git-Url: http://dolda2000.com/gitweb/?p=ashd.git;a=blobdiff_plain;f=src%2Fcallscgi.c;h=48d23628bf92e2bd47f7388d72976b1eb093c44a;hp=6d72f0e7c4786eaf23aeb421076ef7103a71f770;hb=b1b0fe0f4793825232288427da4856e9adf8b868;hpb=32bcaa06f65eba5d0d12cb99aa8c3982708b6f34 diff --git a/src/callscgi.c b/src/callscgi.c index 6d72f0e..48d2362 100644 --- a/src/callscgi.c +++ b/src/callscgi.c @@ -111,9 +111,16 @@ static char *mkanonid(void) return(tmpl); } +static void setupchild(void) +{ + /* PHP appears to not expect to inherit SIGCHLD set to SIG_IGN, so + * reset it for it. */ + signal(SIGCHLD, SIG_DFL); +} + static void startlisten(void) { - int i, fd; + int fd; struct addrinfo *ai, *cai; char *unpath; struct sockaddr_un unm; @@ -191,9 +198,9 @@ static void startlisten(void) exit(1); } if(child == 0) { + setupchild(); dup2(fd, 0); - for(i = 3; i < FD_SETSIZE; i++) - close(i); + close(fd); execvp(*progspec, progspec); flog(LOG_ERR, "callscgi: %s: %s", *progspec, strerror(errno)); _exit(127); @@ -203,15 +210,14 @@ static void startlisten(void) static void startnolisten(void) { - int i, fd; + int fd; if((child = fork()) < 0) { flog(LOG_ERR, "could not fork: %s", strerror(errno)); exit(1); } if(child == 0) { - for(i = 3; i < FD_SETSIZE; i++) - close(i); + setupchild(); if((fd = open("/dev/null", O_RDONLY)) < 0) { flog(LOG_ERR, "/dev/null: %s", strerror(errno)); _exit(127);