Help: lib/shell for ruby 1.9

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

e$B$3$s$I$Oe(B, lib/shell e$B$re(B ruby
1.9(YARV)e$B$KBP1~$7$h$&$H;W$C$F$$$k$N$G$9$,e(B,
Thread.criticale$B$rB?MQ$7$F$$$k$N$Ge(B,
e$B$I$&$7$?$b$s$@$+$HG:$s$G$7$^$9e(B.

e$B$^$:e(B, lib/shell e$B$G$Oe(B, e$B%+%l%s%H%G%#%l%/%H%je(B e$B$re(B
Shelle$B%*%V%8%’%/%H$4$H$Ke(B
e$B;}$F$k$h$&$K$7$F$$$^$9e(B. e$B$G0J2<$N$h$&$Ke(B Thread.critical
e$B$rMQ$$$FB>$N%9e(B
e$B%l%C%I$,B>$N%9%l%C%I$,%+%l%s%H%G%#%l%/%H%j$rJQ99$7$J$$$h$&$K$7$F$$$^$9e(B.

  Thread.critical = true
  back = Dir.pwd
  begin

Dir.chdir @shell.cwd
@files = Dir[pattern]
ensure
Dir.chdir back
Thread.critical = false
end

umaske$BCM$bF1MM$K$7$F$$$^$9e(B.

e$B$Ge(B,
e$B$3$l$i$re(BThread.criticale$B$r;H$o$J$$$GBP1~$9$k$K$O$I$&$9$l$P$h$$$+$Je(B
e$B$He(B… lib/shell
e$B4IM}2<$K$"$k%9%l%C%I$J$iGSB>@)8f$O$G$-$^$9$,e(B, e$B%+%l%s%He(B
e$B%G%#%l%/%H%j$rJQ99$7$?$je(Bumaske$BCM$rJQ99$7$?$j$9$k2DG=@-$N$"$k%9%l%C%I$Oe(B
e$BB>$K$b$"$k$o$1$G$9$+$ie(B…

e$B2?$+NI$$0F$J$$$G$7$g$&$+e(B?

e$B$=$l$H$b$&0l$De(B,
forke$B$7$?8e$N;R%W%m%;%9B&$N%9%l%C%I$O$I$&$9$k$h$&$K$J$je(B
e$B$^$7$?$C$1e(B?
e$B$@$$$VA0$NHG$+$ie(Bkille$B$9$k$h$&$K$J$C$?5$$b$7$F$$$k$N$G$9$,e(B?

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: [email protected] <<—

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:30553] help: lib/shell for ruby 1.9”
on Tue, 13 Mar 2007 19:41:13 +0900, [email protected] (Keiju
ISHITSUKA) writes:

|e$B$3$s$I$Oe(B, lib/shell e$B$re(B ruby 1.9(YARV)e$B$KBP1~$7$h$&$H;W$C$F$$$k$N$G$9$,e(B,
|Thread.criticale$B$rB?MQ$7$F$$$k$N$Ge(B, e$B$I$&$7$?$b$s$@$+$HG:$s$G$7$^$9e(B.

e$B3N$+$K!#e(B

|e$B$^$:e(B, lib/shell e$B$G$Oe(B, e$B%+%l%s%H%G%#%l%/%H%je(B e$B$re(B Shelle$B%*%V%8%’%/%H$4$H$Ke(B
|e$B;}$F$k$h$&$K$7$F$$$^$9e(B. e$B$G0J2<$N$h$&$Ke(B Thread.critical e$B$rMQ$$$FB>$N%9e(B
|e$B%l%C%I$,B>$N%9%l%C%I$,%+%l%s%H%G%#%l%/%H%j$rJQ99$7$J$$$h$&$K$7$F$$$^$9e(B.

e$B$(!<$H!"$^$:Bh0l$Ke(BThread.criticale$B$r;H$($P%3%s%F%-%9%H%9%$%Ce(B
e$B%A$,5/$-$J$$$H8@$&$N$O8m2r$G$9!#e(BThread.criticale$B$O%?%$%^!<$Ke(B
e$B$h$k@Z$jBX$($r6X;$9$k$@$1$G!"$I$3$+$GL@<(E*$J%9%l%C%I@Z$je(B
e$BBX$($,H/@8$9$k$3$H$r;
$a$i$l$^$;$s!#$H$$$&$3$H$O!":G=i$N%3!<e(B
e$B%I$O$b$H$b$H4|BT$9$k$[$I$K$O0BA4$G$OL5$+$C$?$H$$$&$3$H$J$N$@e(B
e$B$H;W$$$^$9!#e(B

e$B$J$*!"e(Bchdire$B$K4X$7$F$Oe(BDir.chdire$B$r%V%m%C%/IU$-$G8F$V$H$$$&5;$,e(B
e$B;H$($k$H;W$$$^$9!#e(B

Dir.chdir(@shell.cwd) do
@files = Dir[patter]
end

e$B;DG0$J$,$ie(Bumaske$B$K$OF1MM$N<jCJ$,MQ0U$5$l$F$$$^$;$s!#$=$b$=$be(B
e$B%W%m%;%9C10L$N35G0$r%9%l%C%IC10L$K8+$;$+$1$k;~E@$GAjEvL5M}$,e(B
e$B$"$k$o$1$G$9$,!#e(B

|e$B$=$l$H$b$&0l$De(B, forke$B$7$?8e$N;R%W%m%;%9B&$N%9%l%C%I$O$I$&$9$k$h$&$K$J$je(B
|e$B$^$7$?$C$1e(B? e$B$@$$$VA0$NHG$+$ie(Bkille$B$9$k$h$&$K$J$C$?5$$b$7$F$$$k$N$G$9$,e(B?

1.8e$B$G$Oe(Bforke$B$7$?0J30$N%9%l%C%I$OA4It;`$K$^$9e(B(e$B$G$be(BOSXe$B$G$OF0$+e(B
e$B$J$$$H$+e(B
[ruby-dev:30581])e$B!#e(Btrunke$B$G$I$&$J$N$+$O$A$g$C$H:#$Oe(B
e$BJ,$+$j$^$;$s!#e(B

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

In [ruby-dev:30585] the message: “[ruby-dev:30585] Re: help: lib/shell
for ruby 1.9”, on Mar/15 12:10(JST)
Yukihiro M. writes:

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

|e$B$3$s$I$Oe(B, lib/shell e$B$re(B ruby 1.9(YARV)e$B$KBP1~$7$h$&$H;W$C$F$$$k$N$G$9$,e(B,
|Thread.criticale$B$rB?MQ$7$F$$$k$N$Ge(B, e$B$I$&$7$?$b$s$@$+$HG:$s$G$7$^$9e(B.

e$B3N$+$K!#e(B

e$B$(!<$H!"$^$:Bh0l$Ke(BThread.criticale$B$r;H$($P%3%s%F%-%9%H%9%$%Ce(B
e$B%A$,5/$-$J$$$H8@$&$N$O8m2r$G$9!#e(BThread.criticale$B$O%?%$%^!<$Ke(B
e$B$h$k@Z$jBX$($r6X;$9$k$@$1$G!"$I$3$+$GL@<(E*$J%9%l%C%I@Z$je(B
e$BB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H$j$"$($:2sHr:v$O$"$k$3$H$K$J$k$N$Ge(B, shell.rb
e$B$N;H$$J}$+$ie(B
e$B8@$C$Fe(B, e$B$"$^$jLdBj$K$J$k$3$H$O$J$$$+$J$H9M$($F$$$^$9e(B.

e$B$H$O$$$(e(B, e$B$J$+$J$+%G%P%C%0$,?J$s$G$$$^$;$s$,e(B…

|e$B$=$l$H$b$&0l$De(B, forke$B$7$?8e$N;R%W%m%;%9B&$N%9%l%C%I$O$I$&$9$k$h$&$K$J$je(B
|e$B$^$7$?$C$1e(B? e$B$@$$$VA0$NHG$+$ie(Bkille$B$9$k$h$&$K$J$C$?5$$b$7$F$$$k$N$G$9$,e(B?

1.8e$B$G$Oe(Bforke$B$7$?0J30$N%9%l%C%I$OA4It;`$K$^$9e(B(e$B$G$be(BOSXe$B$G$OF0$+e(B
e$B$J$$$H$+e(B [ruby-dev:30581])e$B!#e(Btrunke$B$G$I$&$J$N$+$O$A$g$C$H:#$Oe(B
e$BJ,$+$j$^$;$s!#e(B

e$BN;2re(B. e$B$G$be(B, e$BF0$+$J$$$C$F8@$&$N$O$I$&$$$&0UL#$G$9e(B?

e$B$H$j$"$($:e(B, ruby-1.8e$B7O$G%F%9%H$7$F$$$^$9e(B.
Mutex#sleepe$B$r;H$o$J$1$l$Pe(B,
e$B%$%s%?!<%U%’%$%9>e$O8_49@-$H$l$k$O$:$G$9$N$Ge(B.

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: [email protected] <<—

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:30587] Re: help: lib/shell for ruby 1.9”
on Thu, 15 Mar 2007 12:41:35 +0900, [email protected]
(e$B@PDM7=<ye(B) writes:

|>e$B$J$*!"e(Bchdire$B$K4X$7$F$Oe(BDir.chdire$B$r%V%m%C%/IU$-$G8F$V$H$$$&5;$,e(B
|>e$B;H$($k$H;W$$$^$9!#e(B

|e$B$3$l$C$Fe(B, thread safe e$B$G$9e(B? e$B$A$,$$$^$9$h$Me(B?

e$BB>%9%l%C%I$,e(Bchdire$B$7$h$&$H$9$k$HNc30$K$J$j$^$9$+$i!"$H$j$"$(e(B
e$B$:%9%l%C%I%;!<%U$G$9!#$?$@!“8=;~E@$G$Oe(Bmutexe$B$H$+;H$C$F$J$$$se(B
e$B$GHyL/$J%?%$%_%s%0$GLdBj$,H/@8$9$k2DG=@-$O$”$j$^$9$M!#e(B

|>1.8e$B$G$Oe(Bforke$B$7$?0J30$N%9%l%C%I$OA4It;`$K$^$9e(B(e$B$G$be(BOSXe$B$G$OF0$+e(B
|>e$B$J$$$H$+e(B [ruby-dev:30581])e$B!#e(Btrunke$B$G$I$&$J$N$+$O$A$g$C$H:#$Oe(B
|>e$BJ,$+$j$^$;$s!#e(B
|
|e$BN;2re(B. e$B$G$be(B, e$BF0$+$J$$$C$F8@$&$N$O$I$&$$$&0UL#$G$9e(B?

e$B$J$s$+!“e(BOSXe$B$G$OJ#?t%9%l%C%I$,$”$k$He(Bexece$B$,e(BEUNSUPPe$B$G%(%i!<$K$Je(B
e$B$k$=$&$G$9!#e(B[ruby-dev:30581]e$B$O$=$l$KBP1~$9$k%Q%C%A$G$9e(B(1.8e$BMQe(B)e$B!#e(B
e$B<h$j9~$s$G$b$h$5$=$&$G$9$,!"e(B1.8e$B$K$D$$$F$Oe(Bknue$B$5$s$KH=CG$OG$$;e(B
e$B$?J}$,$h$$$G$7$g$&!#e(B

1.9e$B$O$=$s$J4JC1$J$3$H$G$OJR$E$+$J$$5$$,$7$^$9$,!#e(B

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

In [ruby-dev:30588] the message: “[ruby-dev:30588] Re: help: lib/shell
for ruby 1.9”, on Mar/15 15:45(JST) Yukihiro M. writes:

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

|>e$B$J$*!"e(Bchdire$B$K4X$7$F$Oe(BDir.chdire$B$r%V%m%C%/IU$-$G8F$V$H$$$&5;$,e(B
|>e$B;H$($k$H;W$$$^$9!#e(B
|e$B$3$l$C$Fe(B, thread safe e$B$G$9e(B? e$B$A$,$$$^$9$h$Me(B?

e$BB>%9%l%C%I$,e(Bchdire$B$7$h$&$H$9$k$HNc30$K$J$j$^$9$+$i!"$H$j$"$(e(B
e$B$:%9%l%C%I%;!<%U$G$9!#$?$@!“8=;~E@$G$Oe(Bmutexe$B$H$+;H$C$F$J$$$se(B
e$B$GHyL/$J%?%$%_%s%0$GLdBj$,H/@8$9$k2DG=@-$O$”$j$^$9$M!#e(B

e$B$?$7$+$K%9%l%C%I%;!<%U$@$1$Ie(B… e$B$3$l$@$He(B, shell.rb
e$B$K$O;H$($J$$$+$be(B…

e$B$I$&$be(B, Ruby1.8 e$B$Ne(B Mutex e$B$+e(B ConditionVariable
e$B$K%P%0$,$"$k$h$&$J5$$,$7e(B
e$B$^$9e(B.

e$BE:IU$N%9%/%j%W%H$r<B9T$9$k$He(B,
e$B$+$J$j$NIQEY$G%G%C%I%m%C%/$K$J$j$^$9e(B.

e$B$"$He(B, Ruby1.9e$B$NJ}$OBg>fIW$J$N$G$9$,e(B,
e$BBT$A%9%l%C%I$NM%@h=g0L$,5$$K$J$ie(B
e$B$J$$$G$b$J$$$G$9e(B. ConditionVariable#wait
e$B$GBT$C$F$$$k%9%l%C%I$NM%@hEYe(B
e$B$,:GDc$K$J$C$F$$$^$9e(B.

– cut here –
require “thread”

#Thread.abort_on_exception=true

m = Mutex.new
c = ConditionVariable.new

jobs = []

th1 = Thread.start {
Thread.pass
puts “th#1 syncronize enter”
m.synchronize do
puts “th#1 syncronize in”
sleep 1
jobs.delete th1
c.signal
puts “th#1 syncronize exit”
end
}
th2 = Thread.start {
Thread.pass
puts “th#2 syncronize enter”
m.synchronize do
puts “th#2 syncronize in”
sleep 2
jobs.delete th2
c.signal
puts “th#2 syncronize exit”
end
}

jobs.push th1
jobs.push th2

m.synchronize do
while !jobs.empty?
p jobs
c.wait(m)
p jobs
sleep 0.5
end
end

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: [email protected] <<—

e$BKNIt$G$9!#e(B

Yukihiro M. wrote:

e$B$A$c$$$^$9!#e(Bforke$B$7$Fe(Bexece$B$OF0$-$^$9e(B(forke$B$7$?;R%W%m%;%9$K$Oe(Bpthreade$B$,0l8D$7e(B
e$B$+$J$$$+$ie(B)e$B!#e(B[ruby-dev:30581]e$B$O$=$&$G$O$J$/$F!"C1$Ke(BThread.start;
exece$B$Ne(B
e$B$h$&$K%9%l%C%I$r:n$C$F$+$ie(Bmaine$B$,e(Bexece$B$7$h$&$H$7$?$H$-$NOC$G$9!#e(B

e$B$J$s$G$3$N8=>]$,5/$-$k$+$Oe(B[ruby-core:10583]e$B;2>He(B

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

In [ruby-dev:30592] the message: “[ruby-dev:30592] Re: [BUG?] Mutex or
ConditionVariable for ruby 1.8[Re: Re: help: lib/shell for ruby 1.9]”,
on Mar/15 19:18(JST) “Akinori MUSHA” writes:

e$BE:IU$N%9%/%j%W%H$r<B9T$9$k$He(B, e$B$+$J$j$NIQEY$G%G%C%I%m%C%/$K$J$j$^$9e(B.

e$B!!e(Bruby-core e$B$Ge(B ext/thread e$B$N%Q%C%A$,=P$F$*$j!"6a!9<h$j9~$_$^$9!#e(B
e$B%F%9%H$K;H$o$;$F$b$i$$$^$9$M!#e(B

e$B$=$&$+e(B,
e$B>>K$5$s$Oe(B1.8e$B7O$N%a%s%F%J%s%9$O0zB`$7$?$C$FOC$G$7$?$C$1e(B…

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: [email protected] <<—

At Thu, 15 Mar 2007 18:53:46 +0900,
石塚圭樹 wrote:

どうも, Ruby1.8 の Mutex か ConditionVariable にバグがあるような気がし
ます.

添付のスクリプトを実行すると, ã‹ãªã‚Šã®é »åº¦ã§ãƒ‡ãƒƒãƒ‰ãƒ­ãƒƒã‚¯ã«ãªã‚Šã¾ã™.

 ruby-core で ext/thread のパッチが出ており、近々取り込みます。
テストに使わせてもらいますね。


/
/__ __ Akinori.org / MUSHA.org
/ ) ) ) ) / FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp

“Different eyes see different things,
Different hearts beat on different strings –
But there are times for you and me when all such things agree”

At Thu, 15 Mar 2007 19:18:42 +0900,
I wrote:

At Thu, 15 Mar 2007 18:53:46 +0900,
石塚圭樹 wrote:

どうも, Ruby1.8 の Mutex か ConditionVariable にバグがあるような気がし
ます.

添付のスクリプトを実行すると, ã‹ãªã‚Šã®é »åº¦ã§ãƒ‡ãƒƒãƒ‰ãƒ­ãƒƒã‚¯ã«ãªã‚Šã¾ã™.

 ruby-core で ext/thread のパッチが出ており、近々取り込みます。
テストに使わせてもらいますね。

 ruby_1_8 枝に修正を入れました。手元では直ったように見えるので、
お試しいただけますでしょうか。


/
/__ __ Akinori.org / MUSHA.org
/ ) ) ) ) / FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp

“Different eyes see different things,
Different hearts beat on different strings –
But there are times for you and me when all such things agree”

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

In [ruby-dev:30600] the message: “[ruby-dev:30600] Re: [BUG?] Mutex or
ConditionVariable for ruby 1.8[Re: Re: help: lib/shell for ruby 1.9]”,
on Mar/16 16:58(JST) “Akinori MUSHA” writes:

e$B$I$&$be(B, Ruby1.8 e$B$Ne(B Mutex e$B$+e(B ConditionVariable e$B$K%P%0$,$"$k$h$&$J5$$,$7e(B
e$B$^$9e(B.

e$B!!e(Bruby_1_8 e$B;^$K=$@5$rF~$l$^$7$?!#<j85$G$OD>$C$?$h$&$K8+$($k$N$G!"e(B
e$B$*;n$7$$$?$@$1$^$9$G$7$g$&$+!#e(B

e$B;n$7$F$_$^$7$?e(B.
e$B$3$N7o$K$D$$$F$OD>$C$?$h$&$G$9e(B.

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

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: [email protected] <<—

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:30594] Re: [BUG?] Mutex or ConditionVariable
for ruby 1.8[Re: Re: help: lib/shell for ruby 1.9]”
on Thu, 15 Mar 2007 23:13:15 +0900, [email protected] (keiju
ISHITSUKA) writes:

|e$B$=$&$+e(B, e$B>>K$5$s$Oe(B1.8e$B7O$N%a%s%F%J%s%9$O0zB`$7$?$C$FOC$G$7$?$C$1e(B…

e$B$($(!"$h$&$d$/$G$9!#$7$+$b!"0zB`$7$?$iESC<$K;v>p$,J,$+$i$J$$e(B
e$B$H$$$&e(B…e$B!#e(B

                            e$B$=$N$&$AA4LL0zB`!)e(B
                            e$B$^$D$b$He(B e$B$f$-$R$me(B /X|)

At Fri, 16 Mar 2007 17:01:33 +0900,
keiju ISHITSUKA wrote:

お試しいただけますでしょうか。

試してみました.
この件については直ったようです.

 ありがとうございます。(早い!)

 卜部さん、 r12067〜r12069 は ruby_1_8_6 枝にマージ可能です。


/
/__ __ Akinori.org / MUSHA.org
/ ) ) ) ) / FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp

“Different eyes see different things,
Different hearts beat on different strings –
But there are times for you and me when all such things agree”

e$BKNIt$G$9e(B

Akinori MUSHA wrote:

e$B!!KNIt$5$s!"e(B r12067e$B!Ae(Br12069 e$B$Oe(B ruby_1_8_6 e$B;^$K%^!<%82DG=$G$9!#e(B

e$B%^!<%8$7$^$7$?!#e(B