NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

xsrc/57579: ctwm application menu hangs because of SIGCHLD/SIG_IGN/system(3) interaction



>Number:         57579
>Category:       xsrc
>Synopsis:       ctwm application menu hangs because of SIGCHLD/SIG_IGN/system(3) interaction
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    xsrc-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 12 13:25:00 +0000 2023
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The NetBSD SIGCHLDation
>Environment:
>Description:
The recent ctwm-4.1.0 update switched from setting SIGCHLD to a handler that calls waitpid, to setting SIGCHLD to SIG_IGN.

Under POSIX semantics, having SIGCHLD handled by SIG_IGN -- or having the SA_NOCLDWAIT flag set -- means that wait(2) will not return until _all_ children have exited, and then will fail with ECHILD.

POSIX does not require system(3) to cope with SIG_IGN or SA_NOCLDWAIT in the SIGCHLD action, and NetBSD's system(3) does not.  (See https://gnats.netbsd.org/57527 for further discussion of that question.)

Suppose you have an .xsession or .xinitrc file like this:

xterm &
xclock &
exec ctwm

ctwm will inherit the xterm and xclock processes as children of the shell via exec.  If you then try to use the application menu, ctwm will try to run a subprocess with system(3).  system(3) relies on waitpid to wait for _the child it created_ to exit, but because ctwm has set SIGCHLD to SIG_IGN, the call to waitpid in system(3) will -- under POSIX semantics -- wait for _all children of the process_ to exit.  That means ctwm will keep hanging until not just the application it started has exited, but also the xterm and xclock processes.
>How-To-Repeat:
1. Put `xterm & xclock & exec ctwm' in .xsession or .xinitrc.
2. Start ctwm.
3. Launch a program from the applications menu.
>Fix:
Go back to installing a signal handler for SIGCHLD that calls waitpid, instead of setting it to SIG_IGN.



Home | Main Index | Thread Index | Old Index