mirror of
https://repo.or.cz/socat.git
synced 2025-07-17 16:43:24 +00:00
fixed bugs where sub processes would become zombies because the master process did not catch SIGCHLD
This commit is contained in:
parent
c44985fb8d
commit
1f5165b765
13 changed files with 116 additions and 55 deletions
25
xiosigchld.c
25
xiosigchld.c
|
@ -1,5 +1,5 @@
|
|||
/* source: xiosigchld.c */
|
||||
/* Copyright Gerhard Rieger 2001-2006 */
|
||||
/* Copyright Gerhard Rieger 2001-2008 */
|
||||
/* Published under the GNU General Public License V.2, see file COPYING */
|
||||
|
||||
/* this is the source of the extended child signal handler */
|
||||
|
@ -157,3 +157,26 @@ void childdied(int signum) {
|
|||
Info("childdied() finished");
|
||||
errno = _errno;
|
||||
}
|
||||
|
||||
|
||||
int xiosetchilddied(void) {
|
||||
#if HAVE_SIGACTION
|
||||
struct sigaction act;
|
||||
memset(&act, 0, sizeof(struct sigaction));
|
||||
act.sa_flags = SA_NOCLDSTOP|SA_RESTART
|
||||
#ifdef SA_NOMASK
|
||||
|SA_NOMASK
|
||||
#endif
|
||||
;
|
||||
act.sa_handler = childdied;
|
||||
if (Sigaction(SIGCHLD, &act, NULL) < 0) {
|
||||
/*! man does not say that errno is defined */
|
||||
Warn2("sigaction(SIGCHLD, %p, NULL): %s", childdied, strerror(errno));
|
||||
}
|
||||
#else /* HAVE_SIGACTION */
|
||||
if (Signal(SIGCHLD, childdied) == SIG_ERR) {
|
||||
Warn2("signal(SIGCHLD, %p): %s", childdied, strerror(errno));
|
||||
}
|
||||
#endif /* !HAVE_SIGACTION */
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue