[BUG] waitpid for ruby-trunk


#1

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

e$B$3$s$I$Oe(B, ruby-trunk(ruby 1.9.0 (2007-03-14 patchlevel
0)[i686-linux])
e$B$NJ}$N%P%0$rJs9p$7$^$9e(B.

e$B2<5-%9%/%j%W%H$r<B9T$9$k$He(B, e$BB(:B$Ke(B

#<Errno::ECHILD: No child processes>

e$B$,H/@8$7$^$9e(B.

– cut here –

p1 = fork{sleep 10}
p2 = fork{sleep 10}

Thread.start{
begin
puts “wait p#1”
_pid = Process.waitpid(p1, nil)
puts “end p#1”
rescue
p $!
end
}

Thread.start{
begin
puts “wait p#2”
_pid = Process.waitpid(p2, nil)
puts “end p#2”
rescue
p $!
end
}

sleep 20

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: removed_email_address@domain.invalid <<—


#2

e$B$J$+$@$G$9!#e(B

At Thu, 15 Mar 2007 22:59:13 +0900,
Keiju ISHITSUKA wrote in [ruby-dev:30593]:

e$B$3$s$I$Oe(B, ruby-trunk(ruby 1.9.0 (2007-03-14 patchlevel 0)[i686-linux])
e$B$NJ}$N%P%0$rJs9p$7$^$9e(B.

e$B2<5-%9%/%j%W%H$r<B9T$9$k$He(B, e$BB(:B$Ke(B

#<Errno::ECHILD: No child processes>

e$B$,H/@8$7$^$9e(B.

Linux 2.4e$B$G$7$g$&$+!#e(B2.6e$B$@$H@5>o$K=*N;$7$^$9!#e(B
e$B$?$V$s!"e(Bpthread_kill()e$B$,@5$7$$Aj<j$KFO$$$F$J$$$s$8$c$J$$$+$HA[e(B
e$BA|$7$^$9$,!#e(B

-DTHREAD_DEBUG=-1e$B$r$D$1$F%3%s%Q%$%k$7$F!"@hF,$Ke(B
Thread.DEBUG = true
e$B$r$$$l$F%F%9%H$7$F$_$F$/$@$5$$!#e(B

-DTHREAD_DEBUG=1 e$B$Oe(Bminirubye$B$^$G$K$7$H$$$?$[$&$,L5Fq!#e(B


#3

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

In [ruby-dev:30598] the message: “[ruby-dev:30598] Re: [BUG] waitpid for
ruby-trunk”, on Mar/16 12:47(JST)
Nobuyoshi N. writes:

e$B$J$+$@$G$9!#e(B

Linux 2.4e$B$G$7$g$&$+!#e(B2.6e$B$@$H@5>o$K=*N;$7$^$9!#e(B

e$B$=$NDL$j$G$9e(B.

e$B$?$V$s!"e(Bpthread_kill()e$B$,@5$7$$Aj<j$KFO$$$F$J$$$s$8$c$J$$$+$HA[e(B
e$BA|$7$^$9$,!#e(B

-DTHREAD_DEBUG=-1e$B$r$D$1$F%3%s%Q%$%k$7$F!"@hF,$Ke(B
Thread.DEBUG = true
e$B$r$$$l$F%F%9%H$7$F$_$F$/$@$5$$!#e(B

Thread.DEBUG= e$B$O$J$$$H%(%i!<$,=P$^$7$?e(B. Thread::DEBUG = 1
e$B$G<B9T$7$^$7e(B
e$B$?e(B.

-DTHREAD_DEBUG=1 e$B$Oe(Bminirubye$B$^$G$K$7$H$$$?$[$&$,L5Fq!#e(B

e$B2?$H$J$/M}2re(B(^^;

e$B7k2L$O0J2<$N46$8$G$9e(B. e$B$3$l$G$o$+$j$^$9e(B?
e$B$A$J$_$K%F%9%H%9%/%j%W%H$OJQ99e(B
e$B$7$F$$$Fe(B:

p1 = fork{exec “sleep”, “10”}
p2 = fork{exec “sleep”, “10”}

e$B$H$J$C$F$$$^$9e(B.


emperor:/home/keiju/var/src/var.lib/ruby/RubyBase/ruby-trunk# ./ruby
/tmp/test-waitpid.rb
0x4000 - rb_thread_wait_fd_rw(5, read)
0x4000 - enter blocking region (0x81748d8)
0x4000 - leave blocking region (0x81748d8)
0x4000 - rb_thread_wait_fd_rw(5, read): done
0x4000 - rb_thread_wait_fd_rw(5, read)
0x4000 - enter blocking region (0x81748d8)
0x4000 - leave blocking region (0x81748d8)
0x4000 - rb_thread_wait_fd_rw(5, read): done
0x4000 - create - stack size: 524288
0x4000 - create: 0x8181510 (0)0x4000 - create - stack size: 524288
0x8003 - thread start: 0x8181510
0xc004 - thread start: 0x8186178
0x4000 - create: 0x8186178 (0)0x4000 - rb_thread_schedule
0x4000 - rb_thread_alone: 3
0x4000 - rb_thread_schedule/switch start
0x8003 - thread start (get lock): 0x8181510
0x8003 - rb_thread_wait_fd_rw(1, write)
0x8003 - enter blocking region (0x8181510)
0xc004 - thread start (get lock): 0x8186178
0xc004 - rb_thread_wait_fd_rw(1, write)
0xc004 - enter blocking region (0x8186178)
0x8003 - leave blocking region (0x8181510)
0x8003 - rb_thread_schedule
0x8003 - rb_thread_alone: 3
0x8003 - rb_thread_schedule/switch start
0x4000 - rb_thread_schedule/switch done
0x4000 - native_sleep 20
0x4000 - native_sleep: pthread_cond_timedwait start (1174018444,
497774000)
0x8003 - rb_thread_schedule/switch done
0x8003 - rb_thread_wait_fd_rw(1, write): done
wait p#1
wait p#2
0x8003 - enter blocking region (0x8181510)
0x8003 - leave blocking region (0x8181510)
0x8003 - rb_thread_wait_fd_rw(1, write)
0x8003 - enter blocking region (0x8181510)
0x8003 - leave blocking region (0x8181510)
0x8003 - rb_thread_wait_fd_rw(1, write): done
#<Errno::ECHILD: No child processes>
0x8003 - thread end: 0x8181510
0xc004 - leave blocking region (0x8186178)
0xc004 - rb_thread_wait_fd_rw(1, write): done
0xc004 - enter blocking region (0x8186178)
0xc004 - leave blocking region (0x8186178)
0xc004 - rb_thread_wait_fd_rw(1, write)
0xc004 - enter blocking region (0x8186178)
0xc004 - leave blocking region (0x8186178)
0xc004 - rb_thread_schedule
0xc004 - rb_thread_alone: 2
0xc004 - rb_thread_schedule/switch start
0xc004 - rb_thread_schedule/switch done
0xc004 - rb_thread_wait_fd_rw(1, write): done
#<Errno::ECHILD: No child processes>
0xc004 - thread end: 0x8186178

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: removed_email_address@domain.invalid <<—


#4

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

In [ruby-dev:30610] the message: “[ruby-dev:30610] Re: [BUG] waitpid
for ruby-trunk”, on Mar/17 12:16(JST) “KUBO Takehiro” writes:

e$B5WJ]$G$9!#e(B

Linux kernel 2.6 e$B$G$b!"4D6-JQ?te(B LD_ASSUME_KERNEL=2.4.19
e$B$r@_Dj$7$F!“e(BLinuxThreads e$B$r;HMQ$5$;$k$h$&$K$7$?$i!”:F8=$7$^$7$?!#e(B

e$B0J2<$Ne(B LinuxTheads e$B$N@)8B$K$R$C$+$+$C$F$$$k$N$G$7$g$&!#e(B
http://www.linux.or.jp/JM/html/LDP_man-pages/man7/pthreads.7.html

e$B$"$k%9%l%C%I$,e(B fork(2) e$B$r;H$C$F?7$7$$;R%W%m%;%9$r:n@.$7$?>l9g!“e(B
e$B$I$N%9%l%C%I$G$b$3$N;R%W%m%;%9$re(B wait(2) e$B$G$-$k$Y$-$G$”$k!#$7e(B
e$B$+$7$J$,$i!"$3$N<BAu$G$O;R%W%m%;%9$r:n@.$7$?%9%l%C%I$@$1$,$3e(B
e$B$N;R%W%m%;%9$re(B wait(2) e$B$G$-$k!#e(B

e$B$J$k$[$Ie(B… e$B$J$+$J$+1|$,?<$$$G$9$Me(B…

e$B2<5-%9%/%j%W%H$K$7$?$ie(B Process::wiaitpid
e$B$,@5>o$KF0:n$7$^$7$?e(B.
shell.rb e$B$NJ}$bF1MM$K$7$?$iF0:n$9$k$h$&$K$J$C$?$h$&$G$9e(B.

e$B$"$j$,$H$&$4$6$$$^$7$?e(B.


Thread.start{
p1 = fork{exec “sleep”, “1”}
begin
puts “wait p#1”
_pid = Process.waitpid(p1, nil)
puts “end p#1”
rescue
p $!
end
}

Thread.start{
p2 = fork{exec “sleep”, “1”}
begin
puts “wait p#2”
_pid = Process.waitpid(p2, nil)
puts “end p#2”
rescue
p $!
end
}

sleep 20

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: removed_email_address@domain.invalid <<—


#5

e$B5WJ]$G$9!#e(B

On 3/16/07, e$B@PDM7=<ye(B removed_email_address@domain.invalid wrote:

Linux 2.4e$B$G$7$g$&$+!#e(B2.6e$B$@$H@5>o$K=*N;$7$^$9!#e(B

e$B$=$NDL$j$G$9e(B.

Linux kernel 2.6 e$B$G$b!"4D6-JQ?te(B LD_ASSUME_KERNEL=2.4.19
e$B$r@_Dj$7$F!“e(BLinuxThreads
e$B$r;HMQ$5$;$k$h$&$K$7$?$i!”:F8=$7$^$7$?!#e(B

e$B0J2<$Ne(B LinuxTheads e$B$N@)8B$K$R$C$+$+$C$F$$$k$N$G$7$g$&!#e(B
http://www.linux.or.jp/JM/html/LDP_man-pages/man7/pthreads.7.html