Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/freebsd/poudriere.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBryan Drewery <bryan@shatow.net>2020-05-28 20:28:04 +0300
committerBryan Drewery <bryan@shatow.net>2021-09-03 02:20:24 +0300
commitad5828ed33a0aa10ff0dad31de3f1587704781b7 (patch)
treed1e5667de9c0e5bfaaea7661dc4627387d1938e1 /test
parenta1b04a09ce68eadbafe607f8ecaae66d2f7676dd (diff)
locks: Add test for a forked child taking a lock with it
Diffstat (limited to 'test')
-rw-r--r--test/locks_critical_section.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/locks_critical_section.sh b/test/locks_critical_section.sh
index 3d0487e5..095a1445 100644
--- a/test/locks_critical_section.sh
+++ b/test/locks_critical_section.sh
@@ -63,3 +63,24 @@ lock_release TEST
assert 1 ${main_sigint} "INT should be delivered on lock_release"
assert 1 ${main_sigterm} "TERM should be delivered on lock_release"
assert 0 ${main_siginfo} "INFO should not be delivered on lock_release"
+
+# Forking with a lock does bad things
+{
+ lock_acquire TEST 0
+ assert 0 "$?" "lock_acquire"
+
+ (
+ trap - INT
+ lock_have TEST
+ assert_not 0 "$?" "child should not have lock TEST"
+ sleep 300
+ ) &
+ bgpid="$!"
+
+ sleep 2
+ kill_and_wait 10 "${bgpid}"
+ assert 143 "$?" "kill bgpid - it should exit on INT rather than wait"
+
+ lock_release TEST
+ assert 0 "$?" "lock_release"
+}