File: handler.sh

package info (click to toggle)
ltt-control 2.13.15-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 17,656 kB
  • sloc: ansic: 167,287; sh: 27,018; makefile: 2,828; python: 1,380; yacc: 692; lex: 129; java: 109; perl: 99; cpp: 35; xml: 23
file content (49 lines) | stat: -rwxr-xr-x 1,402 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
#
# Copyright (C) 2013 Christian Babeux <christian.babeux@efficios.com>
#
# SPDX-License-Identifier: GPL-2.0-only
#

# System binaries paths.
CAT_BIN="cat"
PGREP_BIN="pgrep"
MKDIR_BIN="mkdir"

# Session name
SESSION_NAME="coredump-handler"

# Sessiond binary name.
SESSIOND_BIN_NAME="lttng-sessiond"

# TODO: Checking for a sessiond lockfile would be more appropriate.
if $PGREP_BIN -u root "${SESSIOND_BIN_NAME}" > /dev/null 2>&1
then
    $LTTNG_BIN snapshot record -s ${SESSION_NAME} > /dev/null 2>&1
fi

# Core file settings.
CORE_PATH="/tmp/lttng/core"
CORE_PREFIX="core"

# Core specifiers, see man core(5)

p=$1 # PID of dumped process
u=$2 # (numeric) real UID of dumped process
g=$3 # (numeric) real GID of dumped process
s=$4 # number of signal causing dump
t=$5 # time of dump, expressed as seconds since the Epoch,
     # 1970-01-01 00:00:00 +0000 (UTC)
h=$6 # hostname (same as nodename returned by uname(2))
e=$7 # executable filename (without path prefix)
E=$8 # pathname of executable, with slashes ('/') replaced
     # by exclamation marks ('!').
c=$9 # core file size soft resource limit of crashing process
     # (since Linux 2.6.24)

# Save core dump from stdin.
$MKDIR_BIN -p "${CORE_PATH}"
$CAT_BIN - > "${CORE_PATH}/${CORE_PREFIX}.$p"

# Optional, chain core dump handler with original systemd script.
#$CAT_BIN - | /usr/lib/systemd/systemd-coredump $p $u $g $s $t $e