Discussion:
bug#25029: shuf generates “Bad file descriptor” error on nfs but only when run as a background process
(too old to reply)
Paul Eggert
2016-11-26 23:49:51 UTC
Permalink
Raw Message
Isn't that a bug in glibc freopen? It shouldn't fail ... merely
because stdin doesn't have a valid file descriptor. If so, we should
fix the Gnulib freopen module to work around the bug.
I did that, by installing the attached patches into Gnulib (first patch)
and into Coreutils (2nd and 3rd patches). This fixes the shuf bug for
me, so closing the bug report. CC'ing to bug-gnulib due to the Gnulib fix.
Pádraig Brady
2016-11-27 00:18:23 UTC
Permalink
Raw Message
Post by Paul Eggert
Isn't that a bug in glibc freopen? It shouldn't fail ... merely
because stdin doesn't have a valid file descriptor. If so, we should
fix the Gnulib freopen module to work around the bug.
I did that, by installing the attached patches into Gnulib (first patch)
and into Coreutils (2nd and 3rd patches). This fixes the shuf bug for
me, so closing the bug report. CC'ing to bug-gnulib due to the Gnulib fix.
Cool thanks. I see it does the equivalent of:

$tool file 0>&- || $tool file </dev/null

Does the freopen module now need to depend on
the dup2 and open modules? For example using dup2(fd, fd)
to test fd validity fails on Linux 2.6.29

thanks,
Pádraig
Paul Eggert
2016-11-27 00:27:26 UTC
Permalink
Raw Message
Post by Pádraig Brady
Does the freopen module now need to depend on
the dup2 and open modules? For example using dup2(fd, fd)
to test fd validity fails on Linux 2.6.29
I tried to avoid that dependency, by using code that checks errno after
dup2 fails, so that the workaround should be attempted only on hosts
with the more-recent freopen bug. I haven't tested it on ancient
GNU/Linux systems, though.

Loading...