File: kill_functions.sh

package info (click to toggle)
util-linux 2.41.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 92,844 kB
  • sloc: ansic: 179,146; sh: 22,716; yacc: 1,284; makefile: 525; xml: 422; python: 316; lex: 89; ruby: 75; csh: 37; exp: 19; sed: 16; perl: 15; sql: 9
file content (29 lines) | stat: -rw-r--r-- 819 bytes parent folder | download | duplicates (6)
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
# kill tests, or command, will not when /proc is missing.
test -d /proc || ts_skip "/proc not available"

# The test_sigreceive is ready when signal process mask contains SIGHUP
function check_test_sigreceive {
	local rc=0
	local pid=$1

	for i in 0.01 0.1 1 1 1 1; do
		if [ ! -f /proc/$pid/status ]; then
			# The /proc exists, but not status file. Because the
			# process already started it is unlikely the file would
			# appear after any amount of waiting.  Try to sleep for
			# moment and hopefully test_sigreceive is ready to be
			# killed.
			echo "kill_functions.sh: /proc/$pid/status: No such file or directory"
			sleep 2
			rc=1
			break
		fi
		sigmask=$((16#$( awk '/SigCgt/ { print $2}' /proc/$pid/status) ))
		if [ $(( $sigmask & 1 )) == 1 ]; then
			rc=1
			break
		fi
		sleep $i
	done
	return $rc
}