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

Can't locate object method "FILENO" [rt.cpan.org #102824] #92

Open
toddr opened this issue May 12, 2017 · 1 comment
Open

Can't locate object method "FILENO" [rt.cpan.org #102824] #92

toddr opened this issue May 12, 2017 · 1 comment
Labels
Bug Break in existing functionality.

Comments

@toddr
Copy link
Member

toddr commented May 12, 2017

Migrated from rt.cpan.org#102824 (status was 'open')

Requestors:

From srezic@cpan.org on 2015-03-17 13:56:24:

If STDERR is tied and does not implement a real filehandle, especially if FILENO is not implemented, then running IPC::Run with redirection fails. Here's a sample script which fails with the error message "Can't locate object method "FILENO" via package "MySTDERR" at /opt/perl-5.18.4/lib/site_perl/5.18.4/IPC/Run.pm line 1126.":

#!/usr/bin/perl

use strict;
use warnings;

use IPC::Run qw(run);

#{ no warnings 'redefine'; *IPC::Run::_debug_fd = sub { }; }

{
    package MySTDERR;
    use Symbol qw(geniosym);
    sub TIEHANDLE { return bless geniosym, __PACKAGE__ }
    sub PRINT { shift; print @_ }
}

tie *STDERR, 'MySTDERR' or die $!;

my $out;
run ["echo", "hello"], ">", \$out;
print "out is $out\n";

__END__

If IPC::Run's _debug_fd method is made into a no-op (see the commented out line), then operation is successful.

Probably the correct solution would be to check if the fileno() call is possible in _debug_fd() (using eval{} or ->can()), and just return undef otherwise.

From toddr@cpan.org on 2016-04-12 23:53:38:

perl recently (5.18?) made fileno get angry if a file handle wasn't open and fileno is called.

@toddr toddr added the Bug Break in existing functionality. label Mar 26, 2018
@toddr
Copy link
Member Author

toddr commented Mar 26, 2018

@eserte IPC::Run seems to heavily use fileno. I don't have any suggestions other than: Don't do that?

Do you have any ideas?

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

No branches or pull requests

1 participant