SIGPIPE ignored before any service starts, and in standalone services

3proxy ignored SIGPIPE only after readconfig(), which starts the
services: a client gone while written to in the meantime killed the
process (as auto's case saw on macOS). Standalone services never ignored
it. Sends pass no MSG_NOSIGNAL, so this is the only guard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir Dubrovin 2026-10-23 13:56:38 +03:00
parent 477a2d3822
commit f9b56fc15d
2 changed files with 9 additions and 1 deletions

View File

@ -467,6 +467,11 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
nsopen(); /* before a chroot in the configuration takes /proc away */ nsopen(); /* before a chroot in the configuration takes /proc away */
#endif #endif
loginit(); /* standard output and error, syslog, before a chroot too */ loginit(); /* standard output and error, syslog, before a chroot too */
#ifndef _WIN32
/* before readconfig() starts the services: a client gone while it is
written to is an error, not the end */
signal(SIGPIPE, SIG_IGN);
#endif
#if defined _WIN32 && !defined _WINCE #if defined _WIN32 && !defined _WINCE
if(service) logstdclose(); if(service) logstdclose();
#endif #endif
@ -546,7 +551,6 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
signal(SIGCONT, mysigpause); signal(SIGCONT, mysigpause);
signal(SIGTERM, mysigterm); signal(SIGTERM, mysigterm);
signal(SIGUSR1, mysigusr1); signal(SIGUSR1, mysigusr1);
signal(SIGPIPE, SIG_IGN);
cyclestep(); cyclestep();
#endif #endif

View File

@ -220,6 +220,10 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
#endif #endif
_3proxy_mutex_init(&tpool.mutex); _3proxy_mutex_init(&tpool.mutex);
loginit(); loginit();
#ifndef _WIN32
/* a client gone while it is written to is an error, not the end */
signal(SIGPIPE, SIG_IGN);
#endif
if((res = srvprepare(&s, argc, argv))) return res; if((res = srvprepare(&s, argc, argv))) return res;
/* errors go to the service's log once there is no standard error */ /* errors go to the service's log once there is no standard error */