summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-06-06 22:45:46 +0200
committerNicholas Clark <nick@ccl4.org>2011-06-11 08:48:13 +0200
commit1ede20e6f8f8e8421610e16743bfed46dc90efb0 (patch)
tree98a199f4f63cc5ffd1e13a45699e2608e0fbf31e
parentea87ae30b28ea730a13b7888089b708bdb0f0991 (diff)
downloadperl-1ede20e6f8f8e8421610e16743bfed46dc90efb0.tar.gz
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.
-rw-r--r--ext/IPC-Open3/lib/IPC/Open3.pm9
1 files 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;