chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Subprocess blocking all threads under certain circumstan


From: Moritz Heidkamp
Subject: [Chicken-users] Subprocess blocking all threads under certain circumstances
Date: Wed, 14 Jul 2010 13:23:03 +0200

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]