Eric Jacoboni
2/16/2006 11:56:00 PM
Yukihiro Matsumoto <matz@ruby-lang.org> writes:
> It does work on my machine (1.8.4 2006-02-15; i686-linux), although I
> have to move trap before fork. Do you mind if I ask you more
> information about the version of your Ruby, and your platform?
In fact, i realize now it's may be a "no-problem": i was thinking that
sleep(3) was not affected by a signal like SIGCHLD so i didn't
understood why catching this signal make sleep stop working. Now, i
know that sleep is affected by any signal not discarded, so i know why my
script doesn't work as I expected :)
My confusion comes from a C program i've written, equivalent to the
Ruby script: in this C program, the sleep(20) call was sleeping 20 sec
in the parent process, despite a sigaction on SIGCHILD: that was not
the case with my Ruby script, where the sleep function in the parent
process stopped working as soon as the child died, hence my trouble.
Actually, i realize now that it was only a question of timing: in the
C program, SIGCHLD was caught *before* the parent process call
sleep(20): so this sleep was not interrupted. In the Ruby script, a
different timing makes the sleep starting before the child
die... (anyway, that's the conclusion i've reached so far...).
I've tried this script with 1.8.4 both on OS-X (DP ports) and FreeBSD
5.2 and 6.0, with or without pthreads. I've also tried to code the
same thing with Python and Perl (with POSIX module) : both languages
produce the same behaviour than Ruby... so i definitively think the
problem came from my misunderstanding of this timing problem.
--
Eric Jacoboni, ne il y a 1443573372 secondes