Avoid non-portable signal(SIGCHLD, SIG_IGN)

Joerg Wunsch j at uriah.heep.sax.de
Sat Apr 12 13:36:19 CDT 2003


while looking for something else in Wine (abnormal VM consumption for
a large listbox creation), i just noticed that scheduler/client.c
tries to perform a

	signal (SIGCHLD, SIG_IGN);

This is the old SysV Release 3 way to tell that automatic zombie
reaping is desired.  (Old BSDs didn't have an option for this at all.)
This variant is unsupported under FreeBSD, and has the major drawback
that unavailability of the desired functionality will remain
completely undetected at compile-time.

The Posix way is to use sigaction(), and set the SA_NOCLDWAIT flag
bit.  This variant is supported under FreeBSD (don't know for the
other BSDs).  It has the added bonus that unavailability of the
automatic zombie reaping feature can be detected at compile-time (the
macro is not defined then).

The attached patch conditionalizes the decision based on the presence
of the SA_NOCLDWAIT macro.  IMHO, it would be even safe(r) to
unconditionally use sigaction() since all the systems that currently
support Wine do have a sigaction() call.  I don't think anyone is
going to port Wine to SVR3.2 anytime soon. ;-)
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
-------------- next part --------------
--- scheduler/client.c.orig	Tue Mar  4 23:18:44 2003
+++ scheduler/client.c	Sat Apr 12 20:23:37 2003
@@ -673,11 +673,22 @@
     TEB *teb = NtCurrentTeb();
     int version, ret;
     int reply_pipe[2];
+    struct sigaction reapchildren;
+    memset( &reapchildren, 0, sizeof reapchildren );
+    reapchildren.sa_flags = SA_NOCLDWAIT;
     /* ignore SIGPIPE so that we get a EPIPE error instead  */
     signal( SIGPIPE, SIG_IGN );
-    /* automatic child reaping to avoid zombies */
+    /* Use the Posix way to automatically reap zombies. */
+    sigaction( SIGCHLD, &reapchildren, 0 );
+    /* Hope that the non-portable old SysV way will work. */
     signal( SIGCHLD, SIG_IGN );
     /* create the server->client communication pipes */
     if (pipe( reply_pipe ) == -1) server_protocol_perror( "pipe" );

More information about the wine-patches mailing list