Bugs: Browse | Submit New | Admin

[#1504] Open3.popen() doesn't set $?

Date:
2005-02-16 16:40
Priority:
3
Submitted By:
Josh Purinton (joshpurinton)
Assigned To:
Akinori MUSHA (knu)
Category:
Files / Dirs / IO
State:
Open
Platform:
 
Summary:
Open3.popen() doesn't set $?

Detailed description
$ ruby -e 'require "open3"; stdin,stdout,stderr = Open3.popen3("/bin/true"); stdin.close; puts $?'
# prints 256
256


If there is a way to get the exit status of the process opened with popen3,
it isn't documented.

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-01-19 03:25
Sender: Zach Dennis

I created open4status based on open3. It returns a fourth element
to the array which is a Process::Status object for the command
ran. This way it allows the user of Open4.popen4status to retrieve
the correct exitstatus.

http://www.continuousthinking.com/assets/2007/1/19/open4status.rb

Since $? is only set by last_status_set process.c, and is not
bound to a method available in ruby environment this seems to
be good solution.
Date: 2007-01-19 02:16
Sender: Ryan Davis

Either submit a patch or stop nagging. The bug has been filed,
that is all that we need.
Date: 2007-01-18 22:42
Sender: Zach Dennis

This bug still exists yet today

zdennis@silver:~$ ruby -v
ruby 1.8.5 (2006-12-25 patchlevel 12) [i486-linux]
zdennis@silver:~$ ruby -e 'require "open3";
stdin,stdout,stderr=Open3.popen3("/bin/false"); puts
$?'
0
zdennis@silver:~$ false
zdennis@silver:~$ echo $?
1
Date: 2006-11-02 16:11
Sender: Josh Purinton

This bug still exists.

$ ruby -e 'require "open3"; stdin,stdout,stderr =
Open3.popen3("/bin/false"); stdin.close; puts $?' #
prints
0, but should print 1

$ ruby -v
ruby 1.8.5 (2006-08-25) [x86_64-linux]
Date: 2006-11-02 07:19
Sender: Ryan Davis

I'm closing this bug due to its age / staleness. I simply can't
triage them all and I have
to cut corners somewhere. If you believe this bug still exists
in the latest version of
ruby 1.8.x, please reopen it and, if you can, attach a minimally
reproducible test case
to help us repro it in 1.8.x (where x >= 5).

Thank you for your support. Things will get better.

Ryan Davis.

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
assigned_tonone2007-06-12 01:22zenspider
category_idMisc / Other Standard Library2007-05-29 17:33zenspider
resolution_idOut of Date2006-11-02 18:17zenspider
status_idClosed2006-11-02 16:11joshpurinton
status_idOpen2006-11-02 07:19zenspider
close_date2006-11-02 07:192006-11-02 07:19zenspider
resolution_idNone2006-11-02 07:19zenspider