aboutsummaryrefslogtreecommitdiffstats
path: root/slowcgi.c
diff options
context:
space:
mode:
authorblambert2013-08-30 07:10:26 +0000
committerWynn Wolf Arbor2020-05-24 12:33:55 +0200
commit19ab07d4020c9d4c2a2503dd05440f0b9227708f (patch)
treeb18e6d67bf4c7bfcbbc31dc503e3001015debfe9 /slowcgi.c
parent703660a6f48c69ffba15b9b703d9f241d591cd1b (diff)
downloadslowcgi-19ab07d4020c9d4c2a2503dd05440f0b9227708f.tar.gz
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 '')
-rw-r--r--slowcgi.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/slowcgi.c b/slowcgi.c
index fa191e6..e8636fa 100644
--- a/slowcgi.c
+++ b/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;