From 8ae2fa65636b732e04e19b2521edc335867ba53b Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 24 Mar 2011 22:58:21 -0400 Subject: [PATCH] fix non-atomicity of puts --- src/stdio/puts.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; } -- 2.25.1