Async signal safe I/O functions for use in metric plugins.
#include <stdarg.h>
#include <stdlib.h>
#include <stddef.h>
Include dependency graph for allinea_safe_syscalls.h
:
This graph shows which files directly or indirectly include this file:
1
5 #ifndef ALLINEA_SAFE_SYSCALLS_H
6 #define ALLINEA_SAFE_SYSCALLS_H
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #include <stdarg.h>
13 #include <stdlib.h>
14 #include <stddef.h>
15
27
33 struct timespec allinea_get_current_time(void);
34
35
37
44 extern int allinea_safe_close(int fd);
45
46
48
53 extern void allinea_safe_fprintf(int fd, const char *format, ...);
54
55
57
67 extern int allinea_safe_open (const char *file, int oflags, ...);
68
69
71
75 extern void allinea_safe_printf(const char *format, ...);
76
77
79
88 extern ssize_t allinea_safe_read(int fd, void *buf, size_t count);
89
90
92
101 extern ssize_t allinea_safe_read_all(int fd, void *buf, size_t count);
102
103
105
115 extern ssize_t allinea_safe_read_all_with_alloc(int fd, void **buf, size_t *count);
116
117
132 extern ssize_t allinea_safe_read_line(int fd, void *buf, size_t count);
133
134
136
141 extern void allinea_safe_vfprintf(int fd, const char *format, va_list ap);
142
143
145
154 extern ssize_t allinea_safe_write(int fd, const void *buf, size_t count);
155
156
158
159 #ifdef __cplusplus
160 }
161 #endif
162
163 #endif
Replacements for common libc utility functions.
Most standard libc functions cannot be used because metric library functions need to be async signal safe. In addition, even basic syscalls (such as read
and write
) cannot be used without risking corruption of some other metrics the enclosing profiler might be tracking
(for example, bytes read or bytes written).
These functions can be safely called inside signal handlers and accommodates I/O being done by the metric plugin without corrupting I/O metrics that are tracked by the enclosing profiler:
struct timespec (void)
int (int fd)
fd
previously opened by allinea_safe_open
(async-signal-safe).
See Memory management functions.void (int fd, const char * format,...)
fprintf
.int (const char * file, int oflags,...)
void (const char * format,...)
printf
.ssize_t (int fd, void * buf, size_t count)
buf
to fd
(async-signal-safe)ssize_t (int fd, void * buf, size_t count)
fd
into buf
(async-signal-safe).ssize_t (int fd, void * buf, size_t * count)
fd
into buf
(async-signal-safe).ssize_t (int fd, void * buf, size_t count)
fd
into buf
(async-signal-safe).void (int fd, const char * format, va_list ap)
vfprintf
.ssize_t (int fd, const void * buf, size_t count)
buf
to fd
(async-signal-safe).See also