Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15013
| Path | csiph.com!fu-berlin.de!usenet.stanford.edu!not-for-mail |
|---|---|
| From | mike b <michallinuxstuff@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | Reading from a file by using its FD returns its contents only once |
| Date | Mon, 31 Dec 2018 02:36:43 +0100 |
| Lines | 78 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.6602.1546220220.1284.bug-bash@gnu.org> (permalink) |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| X-Trace | usenet.stanford.edu 1546220220 897 208.118.235.17 (31 Dec 2018 01:37:00 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=mime-version:from:date:message-id:subject:to; bh=rNcB/Ifv5JumtMxwkQPm/hTqpfYnVvDkStNEmXQcg40=; b=olK6jxn2x+spX4ley9C3/RdZNYMAtIOad2GhUE5yTq8L6AzVyAuZ2HIvoNkyNEsvLC qboxIlqbEDu073SA9v+S2ieIZVf3plrOmdCXqcpoO9Dlolsjuoe5psp/bXA85UeDJ2Ut oht63TOuEhmiWvnKEP0KlXz6p57spbzHVDYzR1G8k87oVqahi7mJJtkKMsGVmEv0+bok g3jXaddWK5XlgILztgxgMDYOrCfxYZfeuNJMu1dFlKOrDQ8jz97lRijN7eXfvzJkGEaa +EgakCDhwNxiraGB5Fsk1dOvivE6uo2LAnB3bllvUuWSo/+Mu2H8UgsUoSzkJZYqYHMH kWkg== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=rNcB/Ifv5JumtMxwkQPm/hTqpfYnVvDkStNEmXQcg40=; b=NuZTcFN3IVMYRzLLgQUhVWtn5bNbOXRg5NYD02Kmw2lDAPh1uPoQQCSqL4KiQMOOKE 1aTAc54h18BnFmNFMqalrEUomZYmkRCTqsrG6cwzfu6Sb3bvEB2BbRlaLl6xmvZveIp8 jT7ZBMe9u8FupWd4G5q/R1MNpKtZ/Zt2TibWb/w7eCwUluY4b3yvxpeIF0EwPI+bwiDi YGmI0htvWW412fw7J8eFv224eElf4E/WTU+MFmhhUINO0NMHR/J6spjm/oTed+GGgWfw 53souK4xP6fDzm3IbPasi9mB6/D9ASw0u6ZwsMe4AsiTxq2DCmbRl938lUnZhDwHzJ+d +IjQ== |
| X-Gm-Message-State | AJcUukd/Zmh3vLCgBHnjiOYdlo3Q/d4b0Jom1iKqSwkM0q+FDqKcFGsC N/rSvsDwAuRjqYg+mMOcT3uzGbMTRn0m5wtbQ/L0XtJ7 |
| X-Google-Smtp-Source | ALg8bN4wHh4/mLMm+RN4CvBfaZYr43uphgVfrWgXWH/DTvPqR0H+CxuK8OqvDpkM2Q9YCWTbZDSj5q7TUu0rJSKNp44= |
| X-Received | by 2002:a17:902:a98c:: with SMTP id bh12mr35944787plb.31.1546220215043; Sun, 30 Dec 2018 17:36:55 -0800 (PST) |
| X-detected-operating-system | by eggs.gnu.org: Genre and OS details not recognized. |
| X-Received-From | 2607:f8b0:4864:20::644 |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.21 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.21 |
| 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 | <http://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> |
| Xref | csiph.com gnu.bash.bug:15013 |
Show key headers only | View raw
Configuration Information:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H -I. -I../. -I.././include -I.././lib -Wdate-time
-D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/bash-7fckc0/bash-4.4=.
-fstack-protector-strong -Wformat -Werror=format-security -Wall -no-pie
-Wno-parentheses -Wno-format-security
uname output: Linux debian9 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2
(2018-10-27) x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.4
Patch Level: 12
Release Status: release
I am not quite sure if this is a bug, but here's what I find as a bit odd
behavior:
# modprobe zram num_devices=0
# exec {add}</sys/class/zram-control/hot_add
# read -r id <&"$add"; echo "$id"
0
# read -r id <&"$add"; echo "$id" # <- $id ends up empty, no data is read
# read -r id </sys/class/zram-control/hot_add; echo "$id"
1
# read -r id </sys/class/zram-control/hot_add; echo "$id"
2
# readlink -f "/proc/$$/fd/$add"
/sys/class/zram-control/hot_add
The above sysfs interface is used for creating a zram device by performing
a read on the hot_add file. The value that should be returned is the id of
the newly created device. In first instance file is opened by dynamically
allocating the fd to use "$add" (the fd) across reads instead of
referencing the file directly. But from the above example you can see that
$id is assigned an actual value only on first read. On every next one, $id
would become empty - when using $add, that is. However, when file is read
in a standard way, by using it directly, everything works as it should.
The above is just an example. Doing reads on any other regular file like
this yields same behavior:
# echo bla >./t
# exec 10<./t
# read -r <&10
# echo $REPLY
bla
# read -r <&10
# echo $REPLY
#
Playing with something like:
# zram=/sys/class/zram/control/hot_add
# c=0; while ((++c <= 3)); do read -r; echo "${REPLY:-NULL}"; done <"$zram"
0
NULL
NULL
#
also gets same results. In contrast to:
# c=0; while (( ++c <= 3 )); do read -r; echo "out: ${REPLY:-NULL}"; done
foo
out: foo
foo
out: foo
foo
out: foo
#
which keeps reading from default stdin (terminal in this case) without any
hiccups (as expected).
So, considering all the above, any hints on why subsequent reads in these
scenarios don't get any data from a file would be really appreciated. :)
Same behavior is seen in 4.3.30 and 5.0 versions.
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Reading from a file by using its FD returns its contents only once mike b <michallinuxstuff@gmail.com> - 2018-12-31 02:36 +0100
csiph-web