Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Unopened filehandle in output redirect" when using output functions and undef as timeout #128

Open
kbucheli opened this issue Jul 12, 2018 · 2 comments

Comments

@kbucheli
Copy link
Contributor

#! /usr/bin/perl

use warnings;
use strict;

use IPC::Run qw(run timeout);
my $output = '';
my $func = sub { $output .= $_[0] };

my $input;
my $timeout;
run(['echo', 'foo'], \$input, $func, $func, $timeout);
print $output;

outputs:

Unopened filehandle in output redirect, command 1 at test.pl line 12.

Version: 20180523.0 (it used to work with v0.96)

@ringerc
Copy link

ringerc commented Feb 25, 2019

I've seen the same with string-references, which is bizarre and unexpected.

@ringerc
Copy link

ringerc commented Feb 26, 2019

At least in my case this was another symptom of #124 . I was passing an undef timer to IPC::Run::start and it somehow landed up being recognised as a GLOB reference, resulting in this error.

Changing

IPC::Run::start([..cmd_args..], ..., $timer);

to

my @ipcrun_args = ([...cmd_args...], ...)
push @ipcrun_args $timer if defined($timer);
IPC::Run::stat @ipcrun_args;

resolved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants