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
PerlIO refuses to read STDOUT or write STDIN #15434
Comments
From @arcPerl refuses to even try to read from STDOUT or write to STDIN, even if the underlying file descriptors are readable and/or writable as appropriate. I originally observed this using a dup'ed STDOUT: a forked process wrote data to stdout, and I wanted to be able to re-read that data after the child exited: open STDOUT, "+>", $file or die; The readline emits a "Filehandle STDOUT opened only for output" warning, and yields undef. My first thought was that dup'ing filehandles should copy the PERLIO_F_CANREAD and PERLIO_F_CANWRITE flags from the original handle to the new one. But that actually isn't sufficient: it's possible for Perl to be started with a readable stdout and/or a writable stdin: $ perl -we '<STDOUT> // die' 1<> /dev/null Running those commands under "strace -e trace=read,write" demonstrates that Perl makes no attempt to read from fd 1 or write to fd 0. Perhaps the simplest fix would be to stop checking those flags before reading from or writing to a filehandle; we can expect the OS to yield EBADF iff the requested action is actually impossible. Alternatively, the flags should be set correctly on any handle that's either dup'ed, or opened using the moral equivalent of fdopen (including the standard filehandles). That presumably involves using fcntl(F_GETFL) on the underlying descriptors in those cases. -- |
From @dcollinsnFixing this would probably resolve a few older bugs involving closing
|
The RT System itself - Status changed from 'new' to 'open' |
From @exodistIs this at all connected to On Jul 10, 2016 10:15 AM, "Dan Collins" <dcollinsn@gmail.com> wrote:
|
From @arcNot directly, at least as far as I can tell; at the very least, fixing Chad Granum <exodist7@gmail.com> wrote:
-- |
Migrated from rt.perl.org#128591 (status was 'open')
Searchable as RT128591$
The text was updated successfully, but these errors were encountered: