xmonad-0.9.1 leaves zombie processes around

Hi, after updating xmonad on my OpenBSD machine from 0.7 to 0.9.1 (built with ghc-6.12.2-rc1), I noticed that xmonad now leaves zombie processes around, i.e. it doesn't properly wait(2) for its terminated child processes. This happens for every single launched (and later terminated) xterm as well as for every launch of dmenu. Does anyone else see this problem? Ciao, Kili

On Sat, Apr 10, 2010 at 08:43:39PM +0200, Matthias Kilian wrote:
after updating xmonad on my OpenBSD machine from 0.7 to 0.9.1 (built with ghc-6.12.2-rc1), I noticed that xmonad now leaves zombie processes around, [...]
The below part from Core.hs is completely wrong, you can't just ignore SIGCHLD and hope for some deity cleaning up the mess. And, BTW the default action of SIGCHLD is SIG_IGN, so both calls of `installHandler sigCHLD ...' are equivalent (and thus bogus). (I can't fix this right now, since I'm still waiting for a ghc rebuild on my machine) Ciao, Kili -- | Ignore SIGPIPE to avoid termination when a pipe is full, and SIGCHLD to -- avoid zombie processes, and clean up any extant zombie processes. installSignalHandlers :: MonadIO m => m () installSignalHandlers = io $ do installHandler openEndedPipe Ignore Nothing installHandler sigCHLD Ignore Nothing try $ fix $ \more -> do x <- getAnyProcessStatus False False when (isJust x) more return () uninstallSignalHandlers :: MonadIO m => m () uninstallSignalHandlers = io $ do installHandler openEndedPipe Default Nothing installHandler sigCHLD Default Nothing return ()

Hello, On Sat, Apr 10, 2010 at 10:05:38PM +0200, Matthias Kilian wrote:
The below part from Core.hs is completely wrong, you can't just ignore SIGCHLD and hope for some deity cleaning up the mess. And, BTW the default action of SIGCHLD is SIG_IGN, so both calls of `installHandler sigCHLD ...' are equivalent (and thus bogus).
On a system conforming to POSIX.1-2001, you just can. The easy solution would be to call sigaction with the SA_NOCLDWAIT flag, but System.Posix.Signals lacks the interface to do this :-(. Maybe we should just add that silly wait-loop sigchld handler. Regards, -- Tomáš Janoušek, a.k.a. Liskni_si, http://work.lisk.in/

2010/4/10 Tomáš Janoušek
Hello,
On Sat, Apr 10, 2010 at 10:05:38PM +0200, Matthias Kilian wrote:
The below part from Core.hs is completely wrong, you can't just ignore SIGCHLD and hope for some deity cleaning up the mess. And, BTW the default action of SIGCHLD is SIG_IGN, so both calls of `installHandler sigCHLD ...' are equivalent (and thus bogus).
On a system conforming to POSIX.1-2001, you just can. The easy solution would be to call sigaction with the SA_NOCLDWAIT flag, but System.Posix.Signals lacks the interface to do this :-(.
So would the right thing be to improve that module and throw a conditional flag into xmonad to use it? -- gwern

* On Saturday, April 10 2010, Gwern Branwen wrote:
2010/4/10 Tomáš Janoušek
: ... On a system conforming to POSIX.1-2001, you just can. The easy solution would be to call sigaction with the SA_NOCLDWAIT flag, but System.Posix.Signals lacks the interface to do this :-(.
So would the right thing be to improve that module and throw a conditional flag into xmonad to use it?
XMonad already does a bit of FFI itself (see Main.hsc), would a bit more hurt much? -- Adam

Hello, On Sat, Apr 10, 2010 at 08:40:07PM -0400, Gwern Branwen wrote:
2010/4/10 Tomáš Janoušek
: On a system conforming to POSIX.1-2001, you just can. The easy solution would be to call sigaction with the SA_NOCLDWAIT flag, but System.Posix.Signals lacks the interface to do this :-(.
So would the right thing be to improve that module and throw a conditional flag into xmonad to use it?
Absolutely. However, it's wired into the RTS, so I just opened a ticket -- http://hackage.haskell.org/trac/ghc/ticket/3980. Since we're trying to maintain compatibility with older GHCs, I'll submit a patch with "a silly wait-loop handler" shortly. Regards, -- Tomáš Janoušek, a.k.a. Liskni_si, http://work.lisk.in/

On Sun, Apr 11, 2010 at 01:36:46AM +0200, Tomá? Janou?ek wrote:
The below part from Core.hs is completely wrong, you can't just ignore SIGCHLD and hope for some deity cleaning up the mess. And, BTW the default action of SIGCHLD is SIG_IGN, so both calls of `installHandler sigCHLD ...' are equivalent (and thus bogus).
On a system conforming to POSIX.1-2001, you just can.
Indeed, someone else just told me that I was wrong...
The easy solution would be to call sigaction with the SA_NOCLDWAIT flag, but System.Posix.Signals lacks the interface to do this :-(.
Maybe we should just add that silly wait-loop sigchld handler.
Better wait. Somehting else must be wrong then, and it may as well be in GHCs libraries. I'll try to setup some test cases for this. Ciao, Kili

Hello, On Sun, Apr 11, 2010 at 05:36:05PM +0200, Matthias Kilian wrote:
Better wait. Somehting else must be wrong then, and it may as well be in GHCs libraries. I'll try to setup some test cases for this.
No. Nobody said that OpenBSD conforms to that POSIX-something. Just apply the patch I just posted to the list and be happy :-). Regards, -- Tomáš Janoušek, a.k.a. Liskni_si, http://work.lisk.in/

On Sun, Apr 11, 2010 at 09:05:30PM +0200, Tomá? Janou?ek wrote:
Better wait. Somehting else must be wrong then, and it may as well be in GHCs libraries. I'll try to setup some test cases for this.
No. Nobody said that OpenBSD conforms to that POSIX-something. Just apply the patch I just posted to the list and be happy :-).
Yes, thanks for the patch. (There are still some strange things wrong with OpenBSD; at least sigaction(2) should be POSIX compliant; on the other hand, the implementation of signal(3) seems to differ from what the manpage says) Ciao, Kili

Matthias Kilian
On Sat, Apr 10, 2010 at 08:43:39PM +0200, Matthias Kilian wrote:
after updating xmonad on my OpenBSD machine from 0.7 to 0.9.1 (built with ghc-6.12.2-rc1), I noticed that xmonad now leaves zombie processes around, [...]
The below part from Core.hs is completely wrong, you can't just ignore SIGCHLD and hope for some deity cleaning up the mess. And, BTW the default action of SIGCHLD is SIG_IGN, so both calls of `installHandler sigCHLD ...' are equivalent (and thus bogus).
Wouldn't it be overall more useful to run a hook on subprocess exit? I would find it useful if I was informed of any abnormal exit values for the programs I run. -- \ Troels /\ Henriksen
participants (5)
-
Adam Vogt
-
Gwern Branwen
-
Matthias Kilian
-
Tomáš Janoušek
-
Troels Henriksen