diff options
author | Bret Lambert <blambert@cvs.openbsd.org> | 2013-08-30 07:10:27 +0000 |
---|---|---|
committer | Bret Lambert <blambert@cvs.openbsd.org> | 2013-08-30 07:10:27 +0000 |
commit | 758d7407db3c762f370a3018e2472cbde44b4401 (patch) | |
tree | 8f86161c5dcecc56b60d02f157022458516d23a6 /usr.sbin/slowcgi/slowcgi.c | |
parent | 4ea8d55b8d205ebc0da9bff47f8ff3076bc6077a (diff) |
If the CGI script died due to receipt of signal, pass that back
to the HTTP frontend as the "application return status".
While here, add a pair of informative debugging statements.
ok florian@
Diffstat (limited to 'usr.sbin/slowcgi/slowcgi.c')
-rw-r--r-- | usr.sbin/slowcgi/slowcgi.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/usr.sbin/slowcgi/slowcgi.c b/usr.sbin/slowcgi/slowcgi.c index fa191e6351f..e8636fa408c 100644 --- a/usr.sbin/slowcgi/slowcgi.c +++ b/usr.sbin/slowcgi/slowcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slowcgi.c,v 1.6 2013/08/26 08:02:03 blambert Exp $ */ +/* $OpenBSD: slowcgi.c,v 1.7 2013/08/30 07:10:26 blambert Exp $ */ /* * Copyright (c) 2013 David Gwynne <dlg@openbsd.org> * Copyright (c) 2013 Florian Obser <florian@openbsd.org> @@ -265,6 +265,8 @@ main(int argc, char *argv[]) if (chdir("/") == -1) lerr(1, "chdir(%s)", pw->pw_dir); + ldebug("chroot: %s", pw->pw_dir); + if (setgroups(1, &pw->pw_gid) || setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) || setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) @@ -329,6 +331,8 @@ slowcgi_listen(char *path, gid_t gid) event_set(&l->ev, fd, EV_READ | EV_PERSIST, slowcgi_accept, l); event_add(&l->ev, NULL); evtimer_set(&l->pause, slowcgi_paused, l); + + ldebug("socket: %s", path); } void @@ -430,12 +434,22 @@ slowcgi_sig_handler(int sig, short event, void *arg) c = ncs->client; break; } - if (c != NULL) { - c->script_status = WEXITSTATUS(status); - if (c->script_flags == (STDOUT_DONE | STDERR_DONE)) - create_end_request(c); - c->script_flags |= SCRIPT_DONE; + if (c == NULL) { + lwarnx("caught exit of unknown child %i", pid); + break; } + + if (WIFSIGNALED(status)) + c->script_status = WTERMSIG(status); + else + c->script_status = WEXITSTATUS(status); + + if (c->script_flags == (STDOUT_DONE | STDERR_DONE)) + create_end_request(c); + c->script_flags |= SCRIPT_DONE; + + ldebug("wait: %s", c->script_name); + break; case SIGPIPE: /* ignore */ break; |