Move to kernel style SPDX license identifiers
[lttng-tools.git] / extras / core-handler / handler.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2013 Christian Babeux <christian.babeux@efficios.com>
4 #
5 # SPDX-License-Identifier: GPL-2.0-only
6 #
7
8 # System binaries paths.
9 CAT_BIN="cat"
10 PGREP_BIN="pgrep"
11 MKDIR_BIN="mkdir"
12
13 # Session name
14 SESSION_NAME="coredump-handler"
15
16 # Sessiond binary name.
17 SESSIOND_BIN_NAME="lttng-sessiond"
18
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
25 # Core file settings.
26 CORE_PATH="/tmp/lttng/core"
27 CORE_PREFIX="core"
28
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
This page took 0.042845 seconds and 5 git commands to generate.