(use posix extras) (set-signal-handler! signal/chld void) (let lp ((n 0)) (receive (in out) (create-pipe) (let ((pid1 (process-fork (lambda () (file-close in) (fprintf (open-output-file* out) "hi, there\n") (exit 0)))) ;; Trigger an early sigchld while reading from pid1's output (pid2 (process-fork void))) (file-close out) (let ((res (read-string #f (open-input-file* in)))) (process-wait pid1) (process-wait pid2) (unless (string=? "hi, there\n" res) (printf "ERROR after ~A runs, got ~S\n" n res) (exit 1)))) (lp (fx+ n 1))))