Bug in 'process'?

Notices and updates
Locked
itistoday
Posts: 429
Joined: Sun Dec 02, 2007 5:10 pm
Contact:

Bug in 'process'?

Post 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?
Get your Objective newLISP groove on.

itistoday
Posts: 429
Joined: Sun Dec 02, 2007 5:10 pm
Contact:

Re: Bug in 'process'?

Post by itistoday »

Same problem with 'fork':

Code: Select all

> (fork) (sleep 2000) (exit)
19389
2000
[shell]$
Get your Objective newLISP groove on.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Bug in 'process'?

Post 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.

itistoday
Posts: 429
Joined: Sun Dec 02, 2007 5:10 pm
Contact:

Re: Bug in 'process'?

Post 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..
Get your Objective newLISP groove on.

Locked