diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index 994d968d871..10a96ab568f 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -1271,6 +1271,13 @@ static int process_kernel(int argc, char* argv[]) { struct iovec_wrapper *iovw; int r; + /* When we're invoked by the kernel, stdout/stderr are closed which is dangerous because the fds + * could get reallocated. To avoid hard to debug issues, let's instead bind stdout/stderr to + * /dev/null. */ + r = rearrange_stdio(STDIN_FILENO, -1, -1); + if (r < 0) + return log_error_errno(r, "Failed to connect stdout/stderr to /dev/null: %m"); + log_debug("Processing coredump received from the kernel..."); iovw = iovw_new();