diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2024-04-06 19:41:17 +0200 |
---|---|---|
committer | Christian Göttsche <cgzones@googlemail.com> | 2024-04-13 21:46:04 +0200 |
commit | 2fafa349a7d133b7237e0f4f94873a5941435b98 (patch) | |
tree | 21f4244a8fa425212e724dcf36d4975dbe503b17 /XUtils.h | |
parent | 49bad52fc2f7f4ebae5ebf33d96e0f01d69ee905 (diff) |
Avoid fprintf in signal handlers
fprintf(3) is not safe to call ins signal handlers due to file buffering
and memory allocations.
Format messages in signal handlers via snprintf(3) and output them via
write(2).
Diffstat (limited to 'XUtils.h')
-rw-r--r-- | XUtils.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -117,6 +117,10 @@ ssize_t xReadfileat(openat_arg_t dirfd, const char* pathname, void* buffer, size ATTR_ACCESS3_R(2, 3) ssize_t full_write(int fd, const void* buf, size_t count); +static inline ssize_t full_write_str(int fd, const char* str) { + return full_write(fd, str, strlen(str)); +} + /* Compares floating point values for ordering data entries. In this function, NaN is considered "less than" any other floating point value (regardless of sign), and two NaNs are considered "equal" regardless of payload. */ |