Browse Source

fix non-atomicity of puts

Rich Felker 14 years ago
parent
commit
8ae2fa6563
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/stdio/puts.c

+ 5 - 1
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;
 }