This is an optimisation. Instead of installing a signal handler that does nothing just ignore the signal. Now to ensure that the cgi processes run with a default SIGPIPE restore it before execve.
-- :wq Claudio Index: slowcgi.c =================================================================== RCS file: /cvs/src/usr.sbin/slowcgi/slowcgi.c,v retrieving revision 1.58 diff -u -p -r1.58 slowcgi.c --- slowcgi.c 8 Jan 2021 22:05:34 -0000 1.58 +++ slowcgi.c 16 Apr 2021 14:54:41 -0000 @@ -148,7 +148,6 @@ SLIST_HEAD(requests_head, requests); struct slowcgi_proc { struct requests_head requests; struct event ev_sigchld; - struct event ev_sigpipe; }; struct fcgi_begin_request_body { @@ -374,11 +373,9 @@ main(int argc, char *argv[]) signal_set(&slowcgi_proc.ev_sigchld, SIGCHLD, slowcgi_sig_handler, &slowcgi_proc); - signal_set(&slowcgi_proc.ev_sigpipe, SIGPIPE, slowcgi_sig_handler, - &slowcgi_proc); + signal(SIGPIPE, SIG_IGN); signal_add(&slowcgi_proc.ev_sigchld, NULL); - signal_add(&slowcgi_proc.ev_sigpipe, NULL); event_dispatch(); return (0); @@ -561,9 +558,6 @@ slowcgi_sig_handler(int sig, short event if (pid == -1 && errno != ECHILD) lwarn("waitpid"); break; - case SIGPIPE: - /* ignore */ - break; default: lerr(1, "unexpected signal: %d", sig); break; @@ -939,6 +933,8 @@ exec_cgi(struct request *c) close(s_in[1]); close(s_out[1]); close(s_err[1]); + + signal(SIGPIPE, SIG_DFL); path = strrchr(c->script_name, '/'); if (path != NULL) {