summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2018-10-12 19:16:53 -0700
committerAllan McRae <allan@archlinux.org>2018-10-21 19:19:48 +1000
commitac959bb9c6ce549047a954109ae825158855e386 (patch)
treec498dff0d2256e6decb9b2a835c7f55959fd9630 /test
parent9886566abb375043740167ce5066f1a186c71176 (diff)
downloadpacman-ac959bb9c6ce549047a954109ae825158855e386.tar.xz
handle EINTR while polling scripts/hooks
If poll() is interrupted by a signal, alpm was closing the socket it uses for listening to script/hook output. This would drop script output at the least and kill the script at the worst. Fixes FS#60396 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'test')
-rw-r--r--test/pacman/tests/TESTS1
-rw-r--r--test/pacman/tests/scriptlet-signal-handling.py15
2 files changed, 16 insertions, 0 deletions
diff --git a/test/pacman/tests/TESTS b/test/pacman/tests/TESTS
index 5deb93c4..dc0b4ec3 100644
--- a/test/pacman/tests/TESTS
+++ b/test/pacman/tests/TESTS
@@ -150,6 +150,7 @@ TESTS += test/pacman/tests/replace102.py
TESTS += test/pacman/tests/replace103.py
TESTS += test/pacman/tests/replace104.py
TESTS += test/pacman/tests/replace110.py
+TESTS += test/pacman/tests/scriptlet-signal-handling.py
TESTS += test/pacman/tests/scriptlet-signal-reset.py
TESTS += test/pacman/tests/scriptlet001.py
TESTS += test/pacman/tests/scriptlet002.py
diff --git a/test/pacman/tests/scriptlet-signal-handling.py b/test/pacman/tests/scriptlet-signal-handling.py
new file mode 100644
index 00000000..e65df55b
--- /dev/null
+++ b/test/pacman/tests/scriptlet-signal-handling.py
@@ -0,0 +1,15 @@
+self.description = "Handle signal interrupts while running scriptlets/hooks"
+
+p1 = pmpkg("dummy")
+p1.install['post_install'] = """
+ kill -INT $PPID # send an arbitrary signal that pacman catches
+ sleep 1 # give alpm time to close the socket if EINTR was not handled
+ echo to-parent # if the interrupt is not handled this will die with SIGPIPE
+ echo success > interrupt_was_handled
+ """
+self.addpkg(p1)
+
+self.args = "-U %s" % p1.filename()
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("FILE_EXIST=interrupt_was_handled")