diff options
Diffstat (limited to 'src/coredump')
-rw-r--r-- | src/coredump/coredump.c | 7 | ||||
-rw-r--r-- | src/coredump/stacktrace.c | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index c7dd61f077..e6063cc980 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -20,6 +20,7 @@ #include <errno.h> #include <stdio.h> +#include <stdio_ext.h> #include <sys/prctl.h> #include <sys/xattr.h> #include <unistd.h> @@ -540,6 +541,8 @@ static int compose_open_fds(pid_t pid, char **open_fds) { if (!stream) return -ENOMEM; + (void) __fsetlocking(stream, FSETLOCKING_BYCALLER); + FOREACH_DIRENT(dent, proc_fd_dir, return -errno) { _cleanup_fclose_ FILE *fdinfo = NULL; _cleanup_free_ char *fdname = NULL; @@ -560,12 +563,12 @@ static int compose_open_fds(pid_t pid, char **open_fds) { fdinfo = fdopen(fd, "re"); if (!fdinfo) { - close(fd); + safe_close(fd); continue; } FOREACH_LINE(line, fdinfo, break) { - fputs_unlocked(line, stream); + fputs(line, stream); if (!endswith(line, "\n")) fputc('\n', stream); } diff --git a/src/coredump/stacktrace.c b/src/coredump/stacktrace.c index d37ffae020..95fd27b79a 100644 --- a/src/coredump/stacktrace.c +++ b/src/coredump/stacktrace.c @@ -20,6 +20,7 @@ #include <dwarf.h> #include <elfutils/libdwfl.h> +#include <stdio_ext.h> #include "alloc-util.h" #include "fd-util.h" @@ -108,7 +109,7 @@ static int thread_callback(Dwfl_Thread *thread, void *userdata) { return DWARF_CB_ABORT; if (c->n_thread != 0) - fputc_unlocked('\n', c->f); + fputc('\n', c->f); c->n_frame = 0; @@ -145,6 +146,8 @@ int coredump_make_stack_trace(int fd, const char *executable, char **ret) { if (!c.f) return -ENOMEM; + (void) __fsetlocking(c.f, FSETLOCKING_BYCALLER); + elf_version(EV_CURRENT); c.elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); |