Project

General

Profile

Bug #5239

bootstraptest/runner.rb: assert_normal_exit logic broken on Debian/GNU kFreeBSD

Added by lucas (Lucas Nussbaum) about 9 years ago. Updated about 9 years ago.

Status:
Rejected
Priority:
Normal
Target version:
ruby -v:
-
Backport:
[ruby-core:39142]

Description

Hi,

assert_normal_exit() breaks on some platforms, such as Debian GNU/kFreeBSD.

It does:

begin
  $stderr.reopen("assert_normal_exit.log", "w")
  io = IO.popen("#{@ruby} -W0 #{filename}")
  pid = io.pid
  th = Thread.new {
    io.read
    io.close
    $?
  }
  if !th.join(timeout)
    Process.kill :KILL, pid
    timeout_signaled = true
  end
  status = th.value
ensure
  $stderr.reopen(old_stderr)
  old_stderr.close
end
if status.signaled?

The problem is that the call to $? in the thread cannot retrieve the exit value of the process started by popen. "$?" is transformed into a wait4() syscall, but wait4 is not allowed to inquire the state of non-child processes. And the popen process is not a child of the sub-thread, it is a child of the main thread.

http://pubs.opengroup.org/onlinepubs/009695399/functions/wait.html confirms that waitpid() is not supposed to work on non-child processes.

It works on Linux because wait4() is friendlier there and accepts to give the state of non-child processes.

This was introduced in svn revision 26700, when a timeout was added.


Files

assert_normal_exit.patch (684 Bytes) assert_normal_exit.patch lucas (Lucas Nussbaum), 08/28/2011 02:13 AM

Also available in: Atom PDF