Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15352 > unrolled thread

Re: cat inside >() inside tee after flock gets stuck

Started byChet Ramey <chet.ramey@case.edu>
First post2019-09-09 16:27 -0400
Last post2019-09-09 16:27 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: cat inside >() inside tee after flock gets stuck Chet Ramey <chet.ramey@case.edu> - 2019-09-09 16:27 -0400

#15352 — Re: cat inside >() inside tee after flock gets stuck

FromChet Ramey <chet.ramey@case.edu>
Date2019-09-09 16:27 -0400
SubjectRe: cat inside >() inside tee after flock gets stuck
Message-ID<mailman.77.1568060874.2190.bug-bash@gnu.org>
On 9/6/19 7:15 PM, Kamil Cukrowski wrote:

> Bash Version: 5.0
> Patch Level: 9
> Release Status: release
> 
> Description:
>     I have the following script to synchronize execution of a command
> substitution using flock:
> 
>         touch /tmp/1
>         echo |
>         (
>             flock 13
>             tee >(
>                cat
>                flock -u 13
>             ) >/dev/null
>             (
>                flock 13
>             ) 13</tmp/1
>         ) 13</tmp/1
> 
>     The purpose of the code is to synchronize the output of the command
> redirection run "inside" `tee` with the rest of the script. For that, the
> "main process" blocks on flock until the command inside redirection is
> finished when it unlocks the flock.
> 
>     However on bash 5.0 The `cat` inside `tee` gets blocked on `read()`.

Thanks for the report.

It's the second `flock 13', because it still has a file descriptor open for
writing on the pipe. The change between bash-4.4 and bash-5.0 was made in
December, 2017 in response to this:

https://lists.gnu.org/archive/html/bug-bash/2017-12/msg00002.html

There was an asymmetry in the code that caused some instances of command
lists to inherit file descriptors from process substitutions performed
earlier in the list.

The only thing that fixing that sacrifices is something like

f=<(echo a); cat "$f"

but that never worked in previous versions of bash anyway.

The fix will be in the next devel branch push.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web