[Piuparts-commits] [SCM] piuparts git repository branch, piatti, updated. 0.44-805-gcb3c644
Andreas Beckmann
debian at abeckmann.de
Tue Jun 19 08:54:36 UTC 2012
The following commit has been merged in the piatti branch:
commit f2b79d100b9edac6e2fcf985f9894dcddaafcbb7
Author: Andreas Beckmann <debian at abeckmann.de>
Date: Fri Jun 15 19:13:49 2012 +0200
p-s: run piuparts in its own process group
This allows to send SIGINT to the process group of piuparts
for better termination and cleanup.
Grant 30 seconds to piuparts for cleaning up properly.
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
diff --git a/debian/changelog b/debian/changelog
index 8ea308e..822b458 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -135,6 +135,7 @@ piuparts (0.45) UNRELEASED; urgency=low
- Test the 'dpkg' package for creating/updating a base_tgz.
- Don't update the tarball for disabled sections.
- Rewrite starting piuparts.
+ - Rewrite stopping piuparts for more reliable cleanup.
* piuparts-report.py:
- Remove known_circular_depends handling.
- Exclude obsolete states from generated report.
diff --git a/piuparts-slave.py b/piuparts-slave.py
index f4eb264..5e03ae5 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -28,7 +28,7 @@ import sys
import stat
import time
import logging
-from signal import alarm, signal, SIGALRM, SIGKILL
+from signal import alarm, signal, SIGALRM, SIGINT, SIGKILL
import subprocess
import fcntl
import random
@@ -452,6 +452,17 @@ def run_test_with_timeout(cmd, maxwait, kill_all=True):
pids = [p.pid]
if kill_all:
pids.extend(get_process_children(p.pid))
+ if p.poll() is None:
+ print 'Sending SIGINT...'
+ try:
+ os.killpg(os.getpgid(p.pid), SIGINT)
+ except OSError:
+ pass
+ # piuparts has 30 seconds to clean up after Ctrl-C
+ for i in range(60):
+ time.sleep(0.5)
+ if p.poll() is not None:
+ break
for pid in pids:
if pid > 0:
try:
@@ -462,7 +473,7 @@ def run_test_with_timeout(cmd, maxwait, kill_all=True):
logging.debug("Executing: %s" % " ".join(cmd))
stdout = ""
- p = subprocess.Popen(cmd,
+ p = subprocess.Popen(cmd, preexec_fn=os.setpgrp,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if maxwait > 0:
signal(SIGALRM, alarm_handler)
--
piuparts git repository
More information about the Piuparts-commits
mailing list