[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Question about forks, pipes and sigchld handling
From: |
Peter Bex |
Subject: |
[Chicken-users] Question about forks, pipes and sigchld handling |
Date: |
Wed, 3 Oct 2012 18:21:45 +0200 |
User-agent: |
Mutt/1.4.2.3i |
Hi all,
I'm trying to figure out the behavior of process-fork and the
handling of signal/chld (SIGCHLD). Here's a simple program
which simply sets up a pipe and forks. The parent process reads
from the pipe, the child writes to it.
(use posix)
#;(set-signal-handler! signal/chld void)
(receive (in out)
(create-pipe)
(process-fork (lambda ()
(file-close in) ; close receiving end
(with-output-to-port (open-output-file* out)
(lambda ()
(display "hello, world\n")
;; If we don't use exit, buffers are discarded by _exit
(exit)))))
(file-close out) ; close sending end
(pp (read-lines (open-input-file* in))))
This program works just fine and prints ("hello, world").
If I uncomment the signal handler code (which should just be a no-op),
it hangs. I don't understand the reason for this. Could anyone
enlighten me as to what's happening here?
Cheers,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
- [Chicken-users] Question about forks, pipes and sigchld handling,
Peter Bex <=