From e6887bddb925a775960a168e4dabcf700b2c376c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hinrik=20=C3=96rn=20Sigur=C3=B0sson?= Date: Tue, 3 May 2011 00:04:26 +0000 Subject: [PATCH] Fix mangled stdio checks. This one passes all tests. --- lib/POE/Wheel/Run.pm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/POE/Wheel/Run.pm b/lib/POE/Wheel/Run.pm index 0b0ef5eaa..b7192c1a8 100644 --- a/lib/POE/Wheel/Run.pm +++ b/lib/POE/Wheel/Run.pm @@ -256,16 +256,15 @@ sub new { ); } -# # Did the user mangle stdio? -# # TODO - This means well, but it doesn't realy work. -# unless (ref($program) eq 'CODE') { -# croak "Someone has closed or moved STDIN... exec() won't find it" -# unless fileno(STDIN) or fileno(STDIN) != 0; -# croak "Someone has closed or moved STDOUT... exec() won't find it" -# unless fileno(STDOUT) or fileno(STDOUT) != 1; -# croak "Someone has closed or moved STDERR... exec() won't find it" -# unless fileno(STDERR) or fileno(STDERR) != 2; -# } + # Did the user mangle stdio? + unless (ref($program) eq 'CODE') { + croak "Someone has closed or moved STDIN... exec() won't find it" + unless defined fileno(STDIN) && fileno(STDIN) == 0; + croak "Someone has closed or moved STDOUT... exec() won't find it" + unless tied(*STDOUT) || defined fileno(STDOUT) && fileno(STDOUT) == 1; + croak "Someone has closed or moved STDERR... exec() won't find it" + unless tied(*STDERR) || defined fileno(STDERR) && fileno(STDERR) == 2; + } my ( $stdin_read, $stdout_write, $stdout_read, $stdin_write,