Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15351
| Path | csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Kamil Cukrowski <kamilcukrowski@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | cat inside >() inside tee after flock gets stuck |
| Date | Sat, 7 Sep 2019 01:15:40 +0200 |
| Lines | 79 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.477.1567820466.2075.bug-bash@gnu.org> (permalink) |
| References | <ce746044-05f6-8dc0-d599-b6a46b9c4704@gmail.com> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | usenet.stanford.edu 1567820467 20637 209.51.188.17 (7 Sep 2019 01:41:07 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| To | bug-bash@gnu.org |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=9t8uXFzyKE5Q07qaLZvLBROvMy6V1b/hQizZtQ3yv8Y=; b=QuXxPlVj24yIVH5tzRHweOZkJY3RqHTfmMI+NknmN8nzNpbBJD3TOw4lTYIJ152uMO Y9Bz3s7RshcF7VS37IiUyNDIQZJNVQWvU5eivvKlwo45Ycs1sbhsuXOtYizJHmT7GAqw aL0878Xw3Kf0eBAHXpjw8PiQ8nOwGRQaJH2WywmPNJAIum1pYW/2NfegrV+MDzPpAYO6 Xy8jc7QLlXONzE3j4i0okkouBbRPQywexxYtln3fphZjyxzLK69qjlMITwqtrKV91T5E p0HXACYz15r6YqUBXPDitVLpPN8oPWzpDRTwXxyaU+2+Q733ONJZKdOjcuv77nczDR01 LtHQ== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=9t8uXFzyKE5Q07qaLZvLBROvMy6V1b/hQizZtQ3yv8Y=; b=lVoybVZGw78M5bGJAEW8r8Z0PAPh0Sf09R93/Wzxw5N06hku37hc9ODQcZ8a+zKomF uYur8G1NGFLpalPMXZWBxueQ0xpNXZ5pvDlbXrosugWoCNGTwwTkL6thDkQrT2wFfdE/ oM7ZgT30rFOX/eCjErpb2enfbGJdsd/8Q8aRAxxVCMzr6F9pDK+VxEz6VtPhhKSnLZAi lfvyG3PZVtMyDFALBJs6VkGPxvRDjT7tv1CGYWexontjFIlAnRHHq7bBrU/cJ/6uSa+3 7MzVDU2kbUOpS2DV++DqW/lnWH6DynlbxZbmfbNFVqLqWoywdyRwvjIo+HC8RU38NO70 ql7w== |
| X-Gm-Message-State | APjAAAWG98KobnH+Asb2NzozJjacAd2p3g3mjpGkvrAahThnxWzB663C YFFC4Mx6Xyi4bwVgmVGB0UFHeBFZ |
| X-Google-Smtp-Source | APXvYqwfaPzu+DSIC3tsOlS8YuAPzwffSnMLKxYfxRjm+FUNbFAUrStiw6OH6GFZx7vA/TnHNVC8Qg== |
| X-Received | by 2002:a2e:3a01:: with SMTP id h1mr7431592lja.171.1567811742083; Fri, 06 Sep 2019 16:15:42 -0700 (PDT) |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.0 |
| Content-Language | en-US |
| X-detected-operating-system | by eggs.gnu.org: Genre and OS details not recognized. |
| X-Received-From | 2a00:1450:4864:20::22e |
| X-Mailman-Approved-At | Fri, 06 Sep 2019 21:41:04 -0400 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.23 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <https://lists.gnu.org/archive/html/bug-bash> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <ce746044-05f6-8dc0-d599-b6a46b9c4704@gmail.com> |
| Xref | csiph.com gnu.bash.bug:15351 |
Show key headers only | View raw
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin' -DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc' -DSYS_BASH_LOGOUT='/etc/bash.bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS -Wno-parentheses -Wno-format-security uname output: Linux leonidas 5.2.11-arch1-1-ARCH #1 SMP PREEMPT Thu Aug 29 08:09:36 UTC 2019 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu 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()`. I have created the following oneliner as an reproducible example: timeout 1 bash -x -c 'touch /tmp/1; echo | ( flock 13; tee >(cat; echo "all ok"; flock -u 13) >/dev/null; ( flock 13 ) 13</tmp/1) 13</tmp/1' || echo "not ok" If I execute it on on any bash<=4 I get `all ok` printed out. However when run under mine kernel 5.2.11, coreutils 8.31, bash version 5.0.9(1) on my updated archilinux, the `cat` inside `tee >(cat ...)` gets stuck. The `echo "all ok"` is never executed. The `timeout 1` fires and `not ok` is printed out. I have also tried `docker run bash:5.0` and various servers I can access - `not ok` is printed out on bash v5. I can also replicate the behavior on `docker run bash:5.0` The issue was first reported by @LEo on stackoverflow thread: https://stackoverflow.com/questions/57813225/how-to-assign-output-of-multiple-shell-commmands-to-variable-when-using-tee/57813297?noredirect=1#comment102083293_57813297 I tried inspecting both `tee` and `cat` under `strace`. Well, `tee` does `close(3)` , where 3 is it's file descriptor to command redirection. And `cat` just blocks on `read()` call. The empty line from `echo |` is printed out by `cat`, you can put something in there, for sure it reads from proper stream. bash<4 closed the stream properly, bash5.0 seems like doesn't do that and the stream is still open and `cat` blocks on `read()` call. Repeat-By: Simply execute: timeout 1 bash -x -c 'touch /tmp/1; echo | ( flock 13; tee >(cat; echo "all ok"; flock -u 13) >/dev/null; ( flock 13 ) 13</tmp/1) 13</tmp/1' || echo "not ok" If `not ok` is printed out, that means that the bug exists. If `all ok` is printed out, that means all is ok.
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
cat inside >() inside tee after flock gets stuck Kamil Cukrowski <kamilcukrowski@gmail.com> - 2019-09-07 01:15 +0200
csiph-web