diff options
| author | Hauke Mehrtens | 2026-05-03 20:52:11 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2026-05-03 23:59:54 +0000 |
| commit | 81527e1f763092688bb10deed0f123f502caf926 (patch) | |
| tree | 489a42be00104ef514cce144d1fad6d5cbafeb54 | |
| parent | 05406f70d05cae77de4e7e4164c79f9c14c2a485 (diff) | |
| download | uhttpd-81527e1f763092688bb10deed0f123f502caf926.tar.gz | |
proc: restore default SIGPIPE disposition in spawned child
main() installs SIG_IGN for SIGPIPE so the daemon survives writes to
disconnected client sockets. Signal dispositions set to SIG_IGN are
preserved across execve(2), so every CGI / Lua / ucode / relay
process spawned through uh_create_process inherits the ignored
SIGPIPE.
Many CGI helpers and shell pipelines rely on SIGPIPE terminating
them when their output is no longer being consumed. With SIGPIPE
ignored, scripts that detect EPIPE only at the libc level (or not
at all) keep running until the script_timeout fires, wasting CPU
and prolonging resource holds tied to a long-gone client.
Reset SIGPIPE to SIG_DFL in the child before invoking the
spawn callback that eventually exec's the script, so children see
the normal POSIX disposition.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
| -rw-r--r-- | proc.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -18,6 +18,7 @@ */ #include <arpa/inet.h> +#include <signal.h> #include <libubox/blobmsg.h> #include "uhttpd.h" @@ -362,6 +363,7 @@ bool uh_create_process(struct client *cl, struct path_info *pi, char *url, close(wfd[1]); uh_close_fds(); + signal(SIGPIPE, SIG_DFL); cb(cl, pi, url); exit(0); } |