[Bug 1660728] [NEW] exit() doesn't close stdin when it's a file
Launchpad Bug Tracker
1660728 at bugs.launchpad.net
Tue Jan 31 18:07:00 UTC 2017
You have been subscribed to a public bug:
There's a bug in the exit() standard library call when stdin is a file
on disk (rather than a pipe or a tty). When exit() is called by a child
process, stdin is not properly closed, which results in it being
extended in the main process. In the case that the main process
repeatedly spawns child processes in a loop that depends on EOF for
termination, this results in an infinite loop.
I've attached a simple program to reproduce the bug. The README in the archive contains more details. Running
$ ./buginlinux < test.in
produces the bug, but running,
$ cat test.in | ./buginlinux
does not produce the bug (thus demonstrating that pipes as stdin are fine, but files as stdin are broken).
There's also a program in the archive with a workaround in it. This
workaround functions by calling fclose(stdin) right before calling
exit(0). This solves the problem and also proves the presence of a bug,
since, as stated in exit(3): "All open stdio(3) streams are flushed and
closed" when exit is called, so there should be the exact same behavior
with or without the fclose call, but evidently there is not.
I strongly suspect that this is a glibc bug but can't file a bug report
directly there because I can't build the latest version of glibc.
** Affects: glibc (Ubuntu)
Importance: Undecided
Status: New
--
exit() doesn't close stdin when it's a file
https://bugs.launchpad.net/bugs/1660728
You received this bug notification because you are a member of Ubuntu Foundations Bugs, which is subscribed to glibc in Ubuntu.
More information about the foundations-bugs
mailing list