From: "Andrew S. Townley" Date: 2005-09-26T01:58:36+09:00 Subject: Re: [PATCH] allow Open3.popen3 to set $? based on grandchild statusrather than child status Hi Ara, Thanks for the pointers. I'll look a little closer into these to see if they're a better fit than my patch. I didn't know about them (of course, I didn't go hunting because from the Pickaxe I thought open3 would do what I needed... I don't really want to use session because I don't need another shell just to spawn what I'm trying to do. That'd be ksh -> ruby -> ksh -> program which seems like more overhead than I want. From your code snippet, Open4 is probably what I really wanted, but I still think that it's a bug that Open3.popen3 doesn't return the status code of the grandchild process. None of the other possible values are really of any interest, IMHO. Thanks again, ast On Sun, 2005-09-25 at 16:43, Ara.T.Howard wrote: > On Sun, 25 Sep 2005, Andrew S. Townley wrote: > > > > > Hi folks, > > > > I was playing with Open3.popen3 to try and manipulate some child > > processes where I needed both the return code and control of stderr, but > > it didn't seem to return the correct exit status. I don't know if this > > is correct or not, but it seems to do what I think it should. > > Maybe there's a lot of code that depends on the existing behavior, but I > > think with the version in 1.8, you never get the return status of the > > grandchild process. Oh, and I also cleaned up the formatting (changed > > tabs to spaces). > > > > I've attached the patch (generated by: $ diff -urN -F^f > > /usr/lib/ruby/1.8/open3.rb open3.rb >/tmp/open3.patch) if anyone's > > interested. > > session allows you to do this - but you'll running through sh/bash like: > > require 'session' > > sh = Session::new > > stdout, stdout = sh.exexute 'a.out' > exit_status = sh.exit_status > > session is also thread safe. > > another thing you might be interested in is open4, eg: > > pid, stdin, stdout, stderr = Open4::popen4 'a.out' > exit_status = Process::waitpid2(cid).exitstatus > > both are at > > http://codeforpeople.com/lib/ruby > http://codeforpeople.com/lib/ruby/session/ > http://codeforpeople.com/lib/ruby/open4/ > > and listed on the raa. > > cheers. > > -a *************************************************************************************************** The information in this email is confidential and may be legally privileged. Access to this email by anyone other than the intended addressee is unauthorized. If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful. If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, any attachments, and any copies thereof from your system. ***************************************************************************************************