summaryrefslogtreecommitdiffstats
path: root/tests/ts/kill/kill_functions.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:10:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:10:49 +0000
commitcfe5e3905201349e9cf3f95d52ff4bd100bde37d (patch)
treed0baf160cbee3195249d095f85e52d20c21acf02 /tests/ts/kill/kill_functions.sh
parentInitial commit. (diff)
downloadutil-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.tar.xz
util-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.zip
Adding upstream version 2.39.3.upstream/2.39.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts/kill/kill_functions.sh')
-rw-r--r--tests/ts/kill/kill_functions.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/ts/kill/kill_functions.sh b/tests/ts/kill/kill_functions.sh
new file mode 100644
index 0000000..4ace3d9
--- /dev/null
+++ b/tests/ts/kill/kill_functions.sh
@@ -0,0 +1,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
+}