Tests: environment: use a context manager to restore original signal handler
[lttng-tools.git] / tests / utils / warn_processes.sh
1 #!/bin/bash
2 #
3 # Copyright (C) 2016 Michael Jeanson <mjeanson@efficios.com>
4 #
5 # SPDX-License-Identifier: GPL-2.0-only
6 #
7
8 if [ -z $PGREP ]; then
9 PGREP=pgrep
10 fi
11
12 if [ x$LTTNG_TOOLS_TESTS_DISABLE_WARN_LTTNG_PROCESSES == x1 ]; then
13 exit
14 fi
15
16 color_error='\E[1;91m'
17 color_reset='\E[0m'
18 color_bold='\E[1m'
19
20 lttng_processes="$("$PGREP" -l 'lttng|gen-ust-.+')"
21
22 if [ $? -eq 0 ]; then
23 pids="$(cut -d ' ' -f 1 <<< "$lttng_processes" | tr '\n' ' ')"
24
25 echo -e "${color_error}Error: the following LTTng processes were detected running on the system:$color_reset"
26 echo
27 echo "$lttng_processes"
28 echo
29 echo -e "Here's how to kill them: ${color_bold}kill -9 $pids$color_reset"
30 echo
31 echo "The test suite will not run in the presence of those processes since its result may not be reliable."
32 echo
33 exit 1
34 fi
This page took 0.045322 seconds and 4 git commands to generate.