X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fcallscgi.c;h=86abb5b4a27a5e1d4e53f2834259ea40d900def6;hb=9c86e33675aa670c4e9ee8da994a682ee676f492;hp=c5b54999583dce03b04337bc47079290950ca4c0;hpb=02cb2a3df58c71a049c6acae8c3eb41be576e3a5;p=ashd.git diff --git a/src/callscgi.c b/src/callscgi.c index c5b5499..86abb5b 100644 --- a/src/callscgi.c +++ b/src/callscgi.c @@ -98,13 +98,14 @@ static char *mkanonid(void) home = getenv("HOME"); if(home && !access(sprintf3("%s/.ashd/sockets/", home), X_OK)) - tmpl = sprintf2("%s/.ashd/sockets/scgi-a-XXXXXX"); + tmpl = sprintf2("%s/.ashd/sockets/scgi-a-XXXXXX", home); else tmpl = sprintf2("/tmp/scgi-a-%i-XXXXXX", getuid()); if((fd = mkstemp(tmpl)) < 0) { flog(LOG_ERR, "could not create anonymous socket `%s': %s", tmpl, strerror(errno)); exit(1); } + close(fd); unlink(tmpl); return(tmpl); } @@ -579,6 +580,11 @@ static void listenloop(struct muth *muth, va_list args) } } +static void sigexit(int sig) +{ + exit(0); +} + static void usage(FILE *out) { fprintf(out, "usage: servescgi [-h] [-N RETRIES] [-i ID] [-u UNIX-PATH] [-t [HOST:]TCP-PORT] [PROGRAM [ARGS...]]\n"); @@ -616,6 +622,8 @@ int main(int argc, char **argv) exit(1); } signal(SIGCHLD, SIG_IGN); + signal(SIGINT, sigexit); + signal(SIGTERM, sigexit); mustart(listenloop, 0); atexit(killcuraddr); ioloop();