Explorar o código

fix non-atomicity of puts

Rich Felker %!s(int64=14) %!d(string=hai) anos
pai
achega
8ae2fa6563
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  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;
 }