about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-03-24 22:58:21 -0400
committerRich Felker <dalias@aerifal.cx>2011-03-24 22:58:21 -0400
commit8ae2fa65636b732e04e19b2521edc335867ba53b (patch)
tree7429156e4c0656230331d3151cd15721d6916892
parentb470030f839a375e5030ec9d44903ef7581c15a2 (diff)
downloadmusl-8ae2fa65636b732e04e19b2521edc335867ba53b.tar.gz
musl-8ae2fa65636b732e04e19b2521edc335867ba53b.tar.xz
musl-8ae2fa65636b732e04e19b2521edc335867ba53b.zip
fix non-atomicity of puts
-rw-r--r--src/stdio/puts.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/stdio/puts.c b/src/stdio/puts.c
index eb70efdc..4c0e583c 100644
--- a/src/stdio/puts.c
+++ b/src/stdio/puts.c
@@ -2,5 +2,9 @@
 
 int puts(const char *s)
 {
-	return -(fputs(s, stdout) < 0 || putchar('\n') < 0);
+	int r;
+	FLOCK(stdout);
+	r = -(fputs(s, stdout) < 0 || putchar('\n') < 0);
+	FUNLOCK(stdout);
+	return r;
 }