From: "Andrew S. Townley" Date: 2005-09-25T22:16:14+09:00 Subject: [PATCH] allow Open3.popen3 to set $? based on grandchild status rather than child status --=-Z81GGuop5WtosZG1KPHQ Content-Type: text/plain Content-Transfer-Encoding: 7bit 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. Cheers, ast P.S. if I don't reply immediately to any responses, I apologize in advance. I'm having serious trouble keeping up with the list volume and the other things I'm supposed to be doing. ;) *************************************************************************************************** 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. *************************************************************************************************** --=-Z81GGuop5WtosZG1KPHQ Content-Disposition: attachment; filename=open3.patch Content-Type: text/x-patch; name=open3.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: base64 LS0tIC91c3IvbGliL3J1YnkvMS44L29wZW4zLnJiCTIwMDMtMDktMTggMTQ6NDM6NDIuMDAwMDAw MDAwICswMTAwDQorKysgb3BlbjMucmIJMjAwNS0wOS0yNSAxMzo1NDoyNy4zNDc3NTM0NDAgKzAx MDANCkBAIC0xLDEzICsxLDE0IEBADQotIyBvcGVuMy5yYjogU3Bhd24gYSBwcm9ncmFtIGxpa2Ug cG9wZW4sIGJ1dCB3aXRoIHN0ZGVyciwgdG9vLiBZb3UgbWlnaHQgYWxzbw0KLSMgd2FudCB0byB1 c2UgdGhpcyBpZiB5b3Ugd2FudCB0byBieXBhc3MgdGhlIHNoZ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