Mercurial > hg
comparison tests/killdaemons.py @ 7344:58fd3c718ca4
tests: add killdaemons helper script
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 07 Nov 2008 16:28:53 -0600 |
parents | |
children | 3b76321aa0de |
comparison
equal
deleted
inserted
replaced
7343:e47dab64be8d | 7344:58fd3c718ca4 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import os, sys, time, errno, signal | |
4 | |
5 # Kill off any leftover daemon processes | |
6 try: | |
7 fp = file(os.environ['DAEMON_PIDS']) | |
8 for line in fp: | |
9 try: | |
10 pid = int(line) | |
11 except ValueError: | |
12 continue | |
13 try: | |
14 os.kill(pid, 0) | |
15 os.kill(pid, signal.SIGTERM) | |
16 for i in range(10): | |
17 time.sleep(0.05) | |
18 os.kill(pid, 0) | |
19 os.kill(pid, signal.SIGKILL) | |
20 except OSError, err: | |
21 if err.errno != errno.ESRCH: | |
22 raise | |
23 fp.close() | |
24 except IOError: | |
25 pass |