Bug#916313: perl: open "|command" does not set up child process's stdin correctly on perl 5.28 (5.24 is OK)

Dominic Hargreaves dom at earth.li
Sat Dec 15 18:19:04 GMT 2018


Control: tags -1 + confirmed
Control: forwarded -1 https://rt.perl.org/Ticket/Display.html?id=133726

On Wed, Dec 12, 2018 at 04:54:22PM -0500, Zygo Blaxell wrote:
> Dear Maintainer,
> 
> The following one-line perl script fails:
> 
> 	perl -e 'close(STDIN); open(CHILD, "|wc -l")'
> 
> On Debian stable (5.24.1-3+deb9u5) it produces:
> 
> 	$ perl -e 'close(STDIN); open(CHILD, "|wc -l")'
> 	0
> 
> but on Debian testing/unstable (5.28.1-1, 5.28.1-3) it produces:
> 
> 	$ perl -e 'close(STDIN); open(CHILD, "|wc -l")'
> 	wc: 'standard input': Bad file descriptor
> 	0
> 	wc: -: Bad file descriptor
> 
> Other variants of open to a command
> (e.g. open(CHILD, "-|") || exec ...) are similarly broken if STDIN is closed.
> 
> This wreaks havoc on Perl filter scripts that pass data between child
> shell commands: the commands unexpectedly get EBADF when reading from
> stdin, or they unexpectedly use one of the other files they open as
> their stdin.

Thanks for the report! After some investigation, I forwarded the report
upstream, and I believe a patch should be available shortly.

Best,
Dominic.




More information about the Perl-maintainers mailing list