From 1ede20e6f8f8e8421610e16743bfed46dc90efb0 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Mon, 6 Jun 2011 22:45:46 +0200 Subject: In IPC::Open3::_open(), use 3 argument open to avoid a special case for STDERR. The code for STDIN and STDOUT never ends up needing to duplicate a reference. The code for STDERR can, because of the earlier special case code to save STDOUT. It was special-cased to use fileno in commit 8b3e92c60014b4e7, in 1998. This was before 3 argument open. With 3 argument open the special case can be avoided. --- ext/IPC-Open3/lib/IPC/Open3.pm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ext/IPC-Open3/lib/IPC/Open3.pm b/ext/IPC-Open3/lib/IPC/Open3.pm index 14c56057e5..b1acfd08c8 100644 --- a/ext/IPC-Open3/lib/IPC/Open3.pm +++ b/ext/IPC-Open3/lib/IPC/Open3.pm @@ -262,23 +262,20 @@ sub _open3 { } if ($dup_wtr) { - xopen \*STDIN, "<&$dad_wtr" if fileno(STDIN) != xfileno($dad_wtr); + xopen \*STDIN, '<&', $dad_wtr if fileno(STDIN) != xfileno($dad_wtr); } else { xclose $dad_wtr; xopen \*STDIN, "<&=" . fileno $kid_rdr; } if ($dup_rdr) { - xopen \*STDOUT, ">&$dad_rdr" if fileno(STDOUT) != xfileno($dad_rdr); + xopen \*STDOUT, '>&', $dad_rdr if fileno(STDOUT) != xfileno($dad_rdr); } else { xclose $dad_rdr; xopen \*STDOUT, ">&=" . fileno $kid_wtr; } if ($dad_rdr ne $dad_err) { if ($dup_err) { - # I have to use a fileno here because in this one case - # I'm doing a dup but the filehandle might be a reference - # (from the special case above). - xopen \*STDERR, ">&" . xfileno($dad_err) + xopen \*STDERR, '>&', $dad_err if fileno(STDERR) != xfileno($dad_err); } else { xclose $dad_err; -- cgit v1.2.1