Fix context mismatch across UST version due to legacy array context field
[lttng-tools.git] / extras / core-handler / handler.sh
CommitLineData
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.
9CAT_BIN="cat"
10PGREP_BIN="pgrep"
11MKDIR_BIN="mkdir"
57f0bd0c 12
c071ccd9
MD
13# Session name
14SESSION_NAME="coredump-handler"
57f0bd0c
CB
15
16# Sessiond binary name.
17SESSIOND_BIN_NAME="lttng-sessiond"
18
5d9ad612
CB
19# TODO: Checking for a sessiond lockfile would be more appropriate.
20if $PGREP_BIN -u root "${SESSIOND_BIN_NAME}" > /dev/null 2>&1
21then
22 $LTTNG_BIN snapshot record -s ${SESSION_NAME} > /dev/null 2>&1
23fi
24
c071ccd9
MD
25# Core file settings.
26CORE_PATH="/tmp/lttng/core"
27CORE_PREFIX="core"
28
57f0bd0c
CB
29# Core specifiers, see man core(5)
30
31p=$1 # PID of dumped process
32u=$2 # (numeric) real UID of dumped process
33g=$3 # (numeric) real GID of dumped process
34s=$4 # number of signal causing dump
35t=$5 # time of dump, expressed as seconds since the Epoch,
36 # 1970-01-01 00:00:00 +0000 (UTC)
37h=$6 # hostname (same as nodename returned by uname(2))
38e=$7 # executable filename (without path prefix)
39E=$8 # pathname of executable, with slashes ('/') replaced
40 # by exclamation marks ('!').
41c=$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.055066 seconds and 4 git commands to generate.