X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fcallscgi.c;h=48d23628bf92e2bd47f7388d72976b1eb093c44a;hb=b1b0fe0f4793825232288427da4856e9adf8b868;hp=b78827c35d6594333612863d6ad4d2e60c2d3d9e;hpb=cc5adcf9bc17252f48365afca2b92cf78d1b7098;p=ashd.git diff --git a/src/callscgi.c b/src/callscgi.c index b78827c..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); @@ -565,7 +571,6 @@ static void sigign(int sig) static void sigexit(int sig) { shutdown(0, SHUT_RDWR); - exit(0); } static void usage(FILE *out) @@ -609,7 +614,7 @@ int main(int argc, char **argv) signal(SIGINT, sigexit); signal(SIGTERM, sigexit); mustart(listenloop, 0); - atexit(killcuraddr); ioloop(); + killcuraddr(); return(0); }