aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-02-12 10:57:49 +0000
committerKeir Fraser <keir.fraser@citrix.com>2008-02-12 10:57:49 +0000
commitb3a389fdfc3a1fe19fd7094b0180e97d49c186dd (patch)
tree5d6cb23621b283a6d1498fcb346ef6c993b26ad7 /tools
parent5c22e77bb7a925056a111a73ce7ea3c3c5491ca9 (diff)
downloadxen-b3a389fdfc3a1fe19fd7094b0180e97d49c186dd.tar.gz
xen-b3a389fdfc3a1fe19fd7094b0180e97d49c186dd.tar.bz2
xen-b3a389fdfc3a1fe19fd7094b0180e97d49c186dd.zip
device-dm: Use SIGHUP before SIGKILL
Make qemu unblock SIGHUP and make sure the default handler is in place. Have the domain killer send SIGHUP to the device-model script, allow the script 10s to clean up, and if still not dead, send SIGKILL. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/ioemu/vl.c6
-rw-r--r--tools/python/xen/xend/image.py17
2 files changed, 18 insertions, 5 deletions
diff --git a/tools/ioemu/vl.c b/tools/ioemu/vl.c
index 01dfef8555..452bfcc555 100644
--- a/tools/ioemu/vl.c
+++ b/tools/ioemu/vl.c
@@ -7928,11 +7928,13 @@ int main(int argc, char **argv)
}
#endif
- /* Unblock SIGTERM, which may have been blocked by the caller */
+ /* Unblock SIGTERM and SIGHUP, which may have been blocked by the caller */
+ signal(SIGHUP, SIG_DFL);
sigemptyset(&set);
sigaddset(&set, SIGTERM);
+ sigaddset(&set, SIGHUP);
if (sigprocmask(SIG_UNBLOCK, &set, NULL) == -1)
- fprintf(stderr, "Failed to unblock SIGTERM\n");
+ fprintf(stderr, "Failed to unblock SIGTERM and SIGHUP\n");
main_loop();
quit_timers();
diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py
index 4ceb36194f..069cde7dbe 100644
--- a/tools/python/xen/xend/image.py
+++ b/tools/python/xen/xend/image.py
@@ -335,16 +335,27 @@ class ImageHandler:
return
if self.pid:
try:
- os.kill(self.pid, signal.SIGKILL)
+ os.kill(self.pid, signal.SIGHUP)
except OSError, exn:
log.exception(exn)
try:
- os.waitpid(self.pid, 0)
+ # Try to reap the child every 100ms for 10s. Then SIGKILL it.
+ for i in xrange(100):
+ (p, rv) = os.waitpid(self.pid, os.WNOHANG)
+ if p == self.pid:
+ break
+ time.sleep(0.1)
+ else:
+ log.warning("DeviceModel %d took more than 10s "
+ "to terminate: sending SIGKILL" % self.pid)
+ os.kill(self.pid, signal.SIGKILL)
+ os.waitpid(self.pid, 0)
except OSError, exn:
# This is expected if Xend has been restarted within the
# life of this domain. In this case, we can kill the process,
# but we can't wait for it because it's not our child.
- pass
+ # We just make really sure it's going away (SIGKILL) first.
+ os.kill(self.pid, signal.SIGKILL)
self.pid = None
state = xstransact.Remove("/local/domain/0/device-model/%i"
% self.vm.getDomid())