Bug #4518

(win32) waitpid returns exit code while the child process still alive.

Added by Akio Tajima about 3 years ago. Updated almost 3 years ago.

[ruby-dev:43344]
Status:Closed
Priority:Normal
Assignee:Akio Tajima
Category:core
Target version:1.9.3
ruby -v:ruby 1.9.3dev (2011-03-22) [i386-mswin32_100] Backport:

Description

=begin
以下のスクリプトを実行すると2~4回目の繰り返しでエラーとなります(test/test_process.rbから抽出して加工)。

coding: utf-8

require 'tmpdir'
require 'pathname'
def withtmpchdir
Dir.mktmpdir {|d|
p d
d = Pathname.new(d).realpath.to
s
Dir.chdir(d) { yield d }
}
end
def writefile(filename, content)
File.open(filename, "w") {|f| f << content }
end
10.times do
with
tmpchdir do
write_file("foo", "sleep 0.1")
ps = (0...3).map { spawn("ruby", "foo") }.sort
ss = Process.waitall
end
end

エラー:
C:/Users/arton/Documents/ruby/src/rubytrunk/lib/fileutils.rb:1308:in rmdir': Permission denied - :/Users/arton/AppData/Local/Temp/d20110322-7200-dxjpnx (Errno::EACCES)
from C:/Users/arton/Documents/ruby/src/rubytrunk/lib/fileutils.rb:1308:in
block in remove_dir1'
...

WIN32APIのGetExitCodeProcessがアプリケーションの終了ステータスを返した時点では、まだプロセスが終了していないことがあるため、子プロセスがテンポラリディレクトリを利用していてEACCESとなるようです。
(実行環境が、4コア Xeonというのが利いているとは思います)
=end

Associated revisions

Revision 31152
Added by Akio Tajima about 3 years ago

  • win32/win32.c: wait process real termination after reading exit code. fixes #4518

History

#1 Updated by Akio Tajima about 3 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r31152.
Akio, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

#2 Updated by Akio Tajima about 3 years ago

=begin
r31152で修正しました。
=end

Also available in: Atom PDF