diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-12-29 21:32:42 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-12-29 21:32:42 +0100 |
commit | 6908189fc496f6acd8755a9b6f00270a7f352dcb (patch) | |
tree | 424b759dd85abae1137cb98b6f0a9183a471c769 | |
parent | 19bb41c3b30a4bcbc62936f082710d5df7c09d55 (diff) |
Properly lock and unlock streams when printing
-rw-r--r-- | cbs.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -286,6 +286,7 @@ die(const char *fmt, ...) va_list ap; va_start(ap, fmt); + flockfile(stderr); fprintf(stderr, "%s: ", *_cbs_argv); if (fmt) { vfprintf(stderr, fmt, ap); @@ -301,6 +302,7 @@ diex(const char *fmt, ...) va_list ap; va_start(ap, fmt); + flockfile(stderr); fprintf(stderr, "%s: ", *_cbs_argv); if (fmt) vfprintf(stderr, fmt, ap); @@ -457,6 +459,7 @@ cmdput(cmd_t c) void cmdputf(FILE *stream, cmd_t cmd) { + flockfile(stream); for (size_t i = 0; i < cmd._len; i++) { bool safe = true; char *p, *q; @@ -484,6 +487,7 @@ cmdputf(FILE *stream, cmd_t cmd) putc(i == cmd._len - 1 ? '\n' : ' ', stream); } + funlockfile(stream); } bool |