Commit | Line | Data |
---|---|---|
57f0bd0c CB |
1 | #!/bin/sh |
2 | # | |
ab5be9fa | 3 | # Copyright (C) 2013 Christian Babeux <christian.babeux@efficios.com> |
57f0bd0c | 4 | # |
ab5be9fa | 5 | # SPDX-License-Identifier: GPL-2.0-only |
57f0bd0c CB |
6 | # |
7 | ||
8 | # System binaries paths. | |
9 | CAT_BIN="cat" | |
10 | PGREP_BIN="pgrep" | |
11 | MKDIR_BIN="mkdir" | |
57f0bd0c | 12 | |
c071ccd9 MD |
13 | # Session name |
14 | SESSION_NAME="coredump-handler" | |
57f0bd0c CB |
15 | |
16 | # Sessiond binary name. | |
17 | SESSIOND_BIN_NAME="lttng-sessiond" | |
18 | ||
5d9ad612 CB |
19 | # TODO: Checking for a sessiond lockfile would be more appropriate. |
20 | if $PGREP_BIN -u root "${SESSIOND_BIN_NAME}" > /dev/null 2>&1 | |
21 | then | |
22 | $LTTNG_BIN snapshot record -s ${SESSION_NAME} > /dev/null 2>&1 | |
23 | fi | |
24 | ||
c071ccd9 MD |
25 | # Core file settings. |
26 | CORE_PATH="/tmp/lttng/core" | |
27 | CORE_PREFIX="core" | |
28 | ||
57f0bd0c CB |
29 | # Core specifiers, see man core(5) |
30 | ||
31 | p=$1 # PID of dumped process | |
32 | u=$2 # (numeric) real UID of dumped process | |
33 | g=$3 # (numeric) real GID of dumped process | |
34 | s=$4 # number of signal causing dump | |
35 | t=$5 # time of dump, expressed as seconds since the Epoch, | |
36 | # 1970-01-01 00:00:00 +0000 (UTC) | |
37 | h=$6 # hostname (same as nodename returned by uname(2)) | |
38 | e=$7 # executable filename (without path prefix) | |
39 | E=$8 # pathname of executable, with slashes ('/') replaced | |
40 | # by exclamation marks ('!'). | |
41 | c=$9 # core file size soft resource limit of crashing process | |
42 | # (since Linux 2.6.24) | |
43 | ||
44 | # Save core dump from stdin. | |
45 | $MKDIR_BIN -p "${CORE_PATH}" | |
46 | $CAT_BIN - > "${CORE_PATH}/${CORE_PREFIX}.$p" | |
47 | ||
48 | # Optional, chain core dump handler with original systemd script. | |
49 | #$CAT_BIN - | /usr/lib/systemd/systemd-coredump $p $u $g $s $t $e |