[Chicken-users] Question about forks, pipes and sigchld handling
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 mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Question about forks, pipes and sigchld handling
On Wed, Oct 03, 2012 at 06:21:45PM +0200, Peter Bex wrote: 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. [program elided] 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? Turns out this was a bug in Chicken core's handling of EINTR in getc() calls: http://lists.nongnu.org/archive/html/chicken-hackers/2012-10/msg00010.html 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 mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users