Sfoglia il codice sorgente

fix non-atomicity of puts

Rich Felker 14 anni fa
parent
commit
8ae2fa6563
1 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  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;
 }