Permalink
Browse files

Avoid silent POE::Wheel::Run failures when stdio has been relocated.

If using POE::Wheel::Run to exec() a program, throw an error if STDIN,
STDOUT and STDERR do not have respective file descriptors 0, 1 and 2.
Previously, POE::Wheel::Run would just fail to work without any
indication why.  Makes the mysterious issue Hinrik found in
rt.cpan.org ticket 67798 less so.
  • Loading branch information...
1 parent 828b323 commit a67aa0e4053bb5eb2658c83366b678c0a510c3b1 @rcaputo committed Apr 30, 2011
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/POE/Wheel/Run.pm
View
@@ -256,6 +256,16 @@ sub new {
);
}
+ # Did the user mangle stdio?
+ 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;
+ }
+
my (
$stdin_read, $stdout_write, $stdout_read, $stdin_write,
$stderr_read, $stderr_write,

0 comments on commit a67aa0e

Please sign in to comment.