diff options
Diffstat (limited to 'man/journal-stream-fd.c')
-rw-r--r-- | man/journal-stream-fd.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/man/journal-stream-fd.c b/man/journal-stream-fd.c index 8aad5ff..595091a 100644 --- a/man/journal-stream-fd.c +++ b/man/journal-stream-fd.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: MIT-0 */ +#define _GNU_SOURCE 1 #include <errno.h> #include <syslog.h> #include <stdio.h> @@ -10,15 +11,16 @@ int main(int argc, char *argv[]) { int fd; FILE *log; + fd = sd_journal_stream_fd("test", LOG_INFO, 1); if (fd < 0) { - errno = -fd; - fprintf(stderr, "Failed to create stream fd: %m\n"); + fprintf(stderr, "Failed to create stream fd: %s\n", strerror(-fd)); return 1; } + log = fdopen(fd, "w"); if (!log) { - fprintf(stderr, "Failed to create file object: %m\n"); + fprintf(stderr, "Failed to create file object: %s\n", strerror(errno)); close(fd); return 1; } |