Fix: unchecked return value in trace_clock_read64_monotonic
[lttng-tools.git] / extras / core-handler / handler.sh
CommitLineData
57f0bd0c
CB
1#!/bin/sh
2#
3# Copyright (C) 2013 - Christian Babeux <christian.babeux@efficios.com>
4#
5# This program is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License
7# as published by the Free Software Foundation; only version 2
8# of the License.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18#
19
20# System binaries paths.
21CAT_BIN="cat"
22PGREP_BIN="pgrep"
23MKDIR_BIN="mkdir"
24LTTNG_BIN="lttng"
25
c071ccd9
MD
26# Session name
27SESSION_NAME="coredump-handler"
57f0bd0c
CB
28
29# Sessiond binary name.
30SESSIOND_BIN_NAME="lttng-sessiond"
31
5d9ad612
CB
32# TODO: Checking for a sessiond lockfile would be more appropriate.
33if $PGREP_BIN -u root "${SESSIOND_BIN_NAME}" > /dev/null 2>&1
34then
35 $LTTNG_BIN snapshot record -s ${SESSION_NAME} > /dev/null 2>&1
36fi
37
c071ccd9
MD
38# Core file settings.
39CORE_PATH="/tmp/lttng/core"
40CORE_PREFIX="core"
41
57f0bd0c
CB
42# Core specifiers, see man core(5)
43
44p=$1 # PID of dumped process
45u=$2 # (numeric) real UID of dumped process
46g=$3 # (numeric) real GID of dumped process
47s=$4 # number of signal causing dump
48t=$5 # time of dump, expressed as seconds since the Epoch,
49 # 1970-01-01 00:00:00 +0000 (UTC)
50h=$6 # hostname (same as nodename returned by uname(2))
51e=$7 # executable filename (without path prefix)
52E=$8 # pathname of executable, with slashes ('/') replaced
53 # by exclamation marks ('!').
54c=$9 # core file size soft resource limit of crashing process
55 # (since Linux 2.6.24)
56
57# Save core dump from stdin.
58$MKDIR_BIN -p "${CORE_PATH}"
59$CAT_BIN - > "${CORE_PATH}/${CORE_PREFIX}.$p"
60
61# Optional, chain core dump handler with original systemd script.
62#$CAT_BIN - | /usr/lib/systemd/systemd-coredump $p $u $g $s $t $e
This page took 0.040711 seconds and 4 git commands to generate.