diff options
author | Timo Teräs <timo.teras@iki.fi> | 2015-09-11 09:41:44 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2015-09-11 09:41:44 +0300 |
commit | 963b00043c4d3fa933ed0c3c5d909ac3bb5d0421 (patch) | |
tree | 79a27e7456e94f5d92abb1118420850c886df1d8 /main/musl/0003-fix-fclose-of-permanent-stdin-out-err-streams.patch | |
parent | 333a16d94df1eddca2b81ea51868a91128505509 (diff) | |
download | aports-963b00043c4d3fa933ed0c3c5d909ac3bb5d0421.tar.bz2 aports-963b00043c4d3fa933ed0c3c5d909ac3bb5d0421.tar.xz |
main/musl: cherry-pick upstream fixes
make previous commits the upstream versions, and add few
additional fixes
Diffstat (limited to 'main/musl/0003-fix-fclose-of-permanent-stdin-out-err-streams.patch')
-rw-r--r-- | main/musl/0003-fix-fclose-of-permanent-stdin-out-err-streams.patch | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/main/musl/0003-fix-fclose-of-permanent-stdin-out-err-streams.patch b/main/musl/0003-fix-fclose-of-permanent-stdin-out-err-streams.patch new file mode 100644 index 0000000000..53d8b65719 --- /dev/null +++ b/main/musl/0003-fix-fclose-of-permanent-stdin-out-err-streams.patch @@ -0,0 +1,50 @@ +From 426a0e2912c07f0e86feee2ed12f24a808eac2f4 Mon Sep 17 00:00:00 2001 +From: Rich Felker <dalias@aerifal.cx> +Date: Wed, 9 Sep 2015 04:31:07 +0000 +Subject: [PATCH] fix fclose of permanent (stdin/out/err) streams +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +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. +--- + src/stdio/fclose.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/stdio/fclose.c b/src/stdio/fclose.c +index 839d88a..d687a87 100644 +--- a/src/stdio/fclose.c ++++ b/src/stdio/fclose.c +@@ -9,7 +9,7 @@ int fclose(FILE *f) + int r; + int perm; + +- FFINALLOCK(f); ++ FLOCK(f); + + __unlist_locked_file(f); + +@@ -26,6 +26,7 @@ int fclose(FILE *f) + + if (f->getln_buf) free(f->getln_buf); + if (!perm) free(f); +- ++ else FUNLOCK(f); ++ + return r; + } +-- +2.5.1 + |