summaryrefslogtreecommitdiff
path: root/src/coredump/coredump.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-02-17 11:10:35 +0100
committerLennart Poettering <lennart@poettering.net>2017-02-17 11:18:18 +0100
commitd14bcb4ea7b71f475fbf05ecca568b534f419b98 (patch)
tree9c83de0fdb86899e17eea08abd8556aa1e9e3b33 /src/coredump/coredump.c
parent86562420ffd571f97c9f43f6517d0f980f04f14e (diff)
downloadsystemd-d14bcb4ea7b71f475fbf05ecca568b534f419b98.tar.gz
coredump: include signal name in journal metadata
(Note that we only do this for the journal metadata, not for the xattrs, as the xattrs are only supposed to store the original 1:1 info we acquired from the kernel.)
Diffstat (limited to 'src/coredump/coredump.c')
-rw-r--r--src/coredump/coredump.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
index 9f60a7e27f..738061bffc 100644
--- a/src/coredump/coredump.c
+++ b/src/coredump/coredump.c
@@ -54,6 +54,7 @@
#include "mkdir.h"
#include "parse-util.h"
#include "process-util.h"
+#include "signal-util.h"
#include "socket-util.h"
#include "special.h"
#include "stacktrace.h"
@@ -1049,16 +1050,18 @@ static int gather_pid_metadata_and_process_special_crash(
char **comm_fallback,
char **comm_ret,
struct iovec *iovec, size_t *n_iovec) {
- /* We need 25 empty slots in iovec!
- * Note that if we fail on oom later on, we do not roll-back changes to the iovec
- * structure. (It remains valid, with the first n_iovec fields initialized.) */
+
+ /* We need 26 empty slots in iovec!
+ *
+ * Note that if we fail on oom later on, we do not roll-back changes to the iovec structure. (It remains valid,
+ * with the first n_iovec fields initialized.) */
_cleanup_free_ char *exe = NULL, *comm = NULL;
uid_t owner_uid;
pid_t pid;
char *t;
const char *p;
- int r;
+ int r, signo;
r = parse_pid(context[CONTEXT_PID], &pid);
if (r < 0)
@@ -1192,6 +1195,9 @@ static int gather_pid_metadata_and_process_special_crash(
if (t)
IOVEC_SET_STRING(iovec[(*n_iovec)++], t);
+ if (safe_atoi(context[CONTEXT_SIGNAL], &signo) >= 0 && SIGNAL_VALID(signo))
+ set_iovec_field(iovec, n_iovec, "COREDUMP_SIGNAL_NAME=SIG", signal_to_string(signo));
+
if (comm_ret) {
*comm_ret = comm;
comm = NULL;
@@ -1203,7 +1209,7 @@ static int gather_pid_metadata_and_process_special_crash(
static int process_kernel(int argc, char* argv[]) {
const char *context[_CONTEXT_MAX];
- struct iovec iovec[27];
+ struct iovec iovec[28];
size_t i, n_iovec, n_to_free = 0;
int r;
@@ -1272,7 +1278,7 @@ static int process_backtrace(int argc, char *argv[]) {
context[CONTEXT_TIMESTAMP] = argv[CONTEXT_TIMESTAMP + 2];
context[CONTEXT_RLIMIT] = argv[CONTEXT_RLIMIT + 2];
- n_allocated = 32; /* 25 metadata, 2 static, +unknown input, rounded up */
+ n_allocated = 33; /* 25 metadata, 2 static, +unknown input, rounded up */
iovec = new(struct iovec, n_allocated);
if (!iovec)
return log_oom();