about summary refs log tree commit diff
path: root/src/thread/clone.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2015-09-09 04:31:07 +0000
committerRich Felker <dalias@aerifal.cx>2015-09-09 04:31:07 +0000
commit426a0e2912c07f0e86feee2ed12f24a808eac2f4 (patch)
treec6c38c6d1fb8959d4614567c38c34da93228bae4 /src/thread/clone.c
parentd8be1bc0193f45d3900f8466f26d1411b7f919c3 (diff)
downloadmusl-426a0e2912c07f0e86feee2ed12f24a808eac2f4.tar.gz
musl-426a0e2912c07f0e86feee2ed12f24a808eac2f4.tar.xz
musl-426a0e2912c07f0e86feee2ed12f24a808eac2f4.zip
fix fclose of permanent (stdin/out/err) streams
this fixes a bug reported by Nuno Gonçalves. previously, calling
fclose on stdin or stdout resulted in deadlock at exit time, since
__stdio_exit attempts to lock these streams to flush/seek them, and
has no easy way of knowing that they were closed.

conceptually, leaving a FILE stream locked on fclose is valid since,
in the abstract machine, it ceases to exist. but to satisfy the
implementation-internal assumption in __stdio_exit that it can access
these streams unconditionally, we need to unlock them.

it's also necessary that fclose leaves permanent streams in a state
where __stdio_exit will not attempt any further operations on them.
fortunately, the call to fflush already yields this property.
Diffstat (limited to 'src/thread/clone.c')
0 files changed, 0 insertions, 0 deletions