sigCHLD signal handling (Was: Re: pipes? threadWaitRead?)
Dean Herington
heringto at cs.unc.edu
Tue Jul 9 01:35:49 EDT 2002
After much study I have a new theory. It appears that the pipe machinery
is working fine, but that sometimes my program fails to "reap" all of its
terminated child processes. I'm using a `sigCHLD` signal handler that
does `getAnyProcessStatus True False` each time it's invoked. It seems
that one or more `sigCHLD` signals are occurring while an instance of the
handler is already running (having presumably blocked `sigCHLD` during its
execution), and hence the "contemporaneous" signals are getting lost.
(Oh, and it seems this unfortunate behavior occurs for me under Linux but
not Solaris.)
How can I avoid losing `sigCHLD` signals?
It seems that use of the `SA_NODEFER` flag on `sigaction` might do the
trick, but that flag is not accessible via `installHandler`.
Dean
On Mon, 8 Jul 2002, Dean Herington wrote:
> I have some GHC-compiled programs that run OK under Sparc/Solaris but
> hang under x86/Linux. I'm using GHC 5.02.3 on both systems (although
> I've tried GHC 5.03.20020410 on Linux with the same failures). I'm
> debugging to narrow the problem down. My current suspicion is that
> closing the write end of a pipe is not always causing the read end to
> see end-of-file. Is there any strangeness relating to this--or perhaps
> with `threadWaitRead` on pipes--that anyone knows about? I sometimes
> use a pipe to have two GHC threads communicate within a single process.
More information about the Glasgow-haskell-bugs
mailing list