summaryrefslogtreecommitdiffstats
path: root/XUtils.h
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2024-04-06 19:41:17 +0200
committerChristian Göttsche <cgzones@googlemail.com>2024-04-13 21:46:04 +0200
commit2fafa349a7d133b7237e0f4f94873a5941435b98 (patch)
tree21f4244a8fa425212e724dcf36d4975dbe503b17 /XUtils.h
parent49bad52fc2f7f4ebae5ebf33d96e0f01d69ee905 (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.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/XUtils.h b/XUtils.h
index 32bc282d..3703f8bc 100644
--- a/XUtils.h
+++ b/XUtils.h
@@ -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. */

© 2014-2024 Faster IT GmbH | imprint | privacy policy