[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bad file descriptor with coproc and pipe
From: |
Michal Sojka |
Subject: |
Re: Bad file descriptor with coproc and pipe |
Date: |
Wed, 05 Feb 2014 22:37:43 +0100 |
User-agent: |
Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) |
On Wed, Feb 05 2014, Chet Ramey wrote:
> On 2/4/14, 2:34 AM, Michal Sojka wrote:
>
>> Bash Version: 4.2
>> Patch Level: 45
>> Release Status: release
>>
>> Description:
>> The following commands fail:
>>
>> coproc while true; do echo $RANDOM; done
>> cat <&${COPROC[0]} | cat
>>
>> The resulting error message is:
>>
>> bash: ${COPROC[0]}: Bad file descriptor
>
> Bash closes file descriptors associated with coprocs in child processes,
> since they are pipes. It's even more careful when those child processes
> are part of pipelines. It's really a bad idea to have pipe file
> descriptors open in multiple processes; that prevents SIGPIPE generation
> and EOF on read when one writer exits.
Thanks for the explanation. Then the bug is that it is not documented:
https://www.gnu.org/software/bash/manual/bashref.html#Coprocesses
Btw. zsh allows using file descriptors this way.
Best regards,
-Michal