Page 1 of 1

Bug in 'process'?

Posted: Wed Jun 30, 2010 10:50 pm
by itistoday
v.10.2.9

Code: Select all

> (begin (process "ls") (sleep 2000) (println "hi"))
hi
"hi"
Or another version:

Code: Select all

> ((fn () (sleep 2000) (println "foo")) (process "ls"))
foo
"foo"
That happens instantly. There's no delay despite the (sleep 2000) call. Shouldn't there be a delay?

Re: Bug in 'process'?

Posted: Wed Jun 30, 2010 10:59 pm
by itistoday
Same problem with 'fork':

Code: Select all

> (fork) (sleep 2000) (exit)
19389
2000
[shell]$

Re: Bug in 'process'?

Posted: Thu Jul 01, 2010 12:40 am
by Lutz
The finishing 'process' and finishing 'fork' will signal the parent and cancel the 'sleep' via SIGCHLD (signal 20). This is how Unix is expected to work.

You could set the signal to either 'nil' or 'true' for SIG_IGN (ignore) or SIG_DFL (default, which in case of SIGCHLD is SIG_IGN again)).

Code: Select all

(signal 20 nil) 
(fork) (sleep 1000) (println "hi"))
now the finishing 'fork' will not interrupt the 'sleep' in the parent.

Of course a 'sleep' inside the child process is not a problem:

Code: Select all

(fork (begin (sleep 1000) (println "hi")))
and doesn't need any signals to be handled.

Re: Bug in 'process'?

Posted: Thu Jul 01, 2010 1:11 am
by itistoday
OK thanks, either I forgot about that, or I never knew it to begin with. :-p

Maybe that could be mentioned in the fork/process docs? Seems like something that could trip up a lot of folks..