Dear Chickeneers,

I am by no means an expert of subprocesses, (non-)blocking I/O and
threads (I hope it doesn't show too much), so maybe somebody here can
clarify this for me: I'm using posix#process to start a subprocess from
a separate thread. Its documentation states: 

| Blocking reads and writes to or from the ports returned by process
| only block the current thread, not other threads executing
| concurrently.

And it works as advertised. However, if I close both the input and the
output ports of the process, all other threads seem to be blocked. If I
close none of them or only one of them, it works. The following silly
program demonstrates this behavior:

  (use srfi-18 posix)

  (define start (current-seconds))

  (thread-start! (lambda ()
                   (receive (in out pid)
                     (process "sleep 5")
                     (close-output-port out)
                     (close-input-port in))))

  (thread-sleep! 1)
  (print (- (current-seconds) start) " second(s) passed")


Try commenting out any or both of the close-*put-port calls. I tried
this with Chicken 4.5.0, linux-unix-gnu-x86 [ manyargs dload ptables ].


Thanks in advance!
Moritz

_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to