Parcourir la source

fix non-atomicity of puts

Rich Felker il y a 14 ans
Parent
commit
8ae2fa6563
1 fichiers modifiés avec 5 ajouts et 1 suppressions
  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;
 }