newLISP Fan Club

Forum => newLISP newS => Topic started by: itistoday on June 30, 2010, 03:50:31 PM

Title: Bug in 'process'?
Post by: itistoday on June 30, 2010, 03:50:31 PM
v.10.2.9


> (begin (process "ls") (sleep 2000) (println "hi"))
hi
"hi"


Or another version:


> ((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?
Title: Re: Bug in 'process'?
Post by: itistoday on June 30, 2010, 03:59:11 PM
Same problem with 'fork':


> (fork) (sleep 2000) (exit)
19389
2000
[shell]$
Title: Re: Bug in 'process'?
Post by: Lutz on June 30, 2010, 05:40:52 PM
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)).


(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:


(fork (begin (sleep 1000) (println "hi")))

and doesn't need any signals to be handled.
Title: Re: Bug in 'process'?
Post by: itistoday on June 30, 2010, 06:11:38 PM
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..