[Win32utils-devel] [ win32utils-Patches-4121 ] Make it possible to read process exit status

noreply at rubyforge.org noreply at rubyforge.org
Sun Jul 2 22:48:18 EDT 2006


Patches item #4121, was opened at 2006-04-16 10:07
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=413&aid=4121&group_id=85

Category: win32-open3
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 3
Submitted By: Samuel Tesla (stesla)
Assigned to: Nobody (None)
Summary: Make it possible to read process exit status

Initial Comment:
The UNIX Open3 sets the global $? to a Process::Status object so that one can read the exit status of the sub process.

It seems that one is not supposed to fiddle with /that/ variable, but we can make our own.  This patch adds a #last_status method to both the Open3 and Open4 modules that returns a Process::Status object that is set when the pipes are closed (similarly to how Ruby does it in io.c).

I also made popen3 and popen4 return the object when they're called with a block.  I figured it was as neat idea.

----------------------------------------------------------------------

>Comment By: Daniel Berger (djberg96)
Date: 2006-07-02 19:48

Message:
Incorporated into 0.2.3. :)

- Dan

----------------------------------------------------------------------

Comment By: Samuel Tesla (stesla)
Date: 2006-04-23 10:50

Message:
I figured out how to get to the global that $? reads from,
so this new patch makes win32-open3 pretty much behave
exactly like the unix open3.

----------------------------------------------------------------------

Comment By: Samuel Tesla (stesla)
Date: 2006-04-17 15:57

Message:
One thing to note.  My C-foo on windows isn't the greatest.

There /is/ a global variable in process.c called
rb_last_status which is what is hooked up to $?.  In io.c
and eval.c that variable is used as an extern.  I don't know
if you can get to that from a DLL.  I tried just doing
"extern VALUE rb_last_status" but always got a blow-up when
I assigned to it.  If there's some way to declare it so that
we can get to it from inside the module, that would probably
be better than #last_status.

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=413&aid=4121&group_id=85


More information about the win32utils-devel mailing list