Show More
@@ -78,18 +78,20 b' def killdaemons(pidfile, tryhard=True, r' | |||||
78 | logfn = lambda s: s |
|
78 | logfn = lambda s: s | |
79 | # Kill off any leftover daemon processes |
|
79 | # Kill off any leftover daemon processes | |
80 | try: |
|
80 | try: | |
81 | fp = open(pidfile) |
|
81 | pids = [] | |
82 | for line in fp: |
|
82 | with open(pidfile) as fp: | |
83 |
|
|
83 | for line in fp: | |
84 |
|
|
84 | try: | |
85 |
|
|
85 | pid = int(line) | |
86 |
|
|
86 | if pid <= 0: | |
87 |
|
|
87 | raise ValueError | |
88 | logfn('# Not killing daemon process %s - invalid pid' |
|
88 | except ValueError: | |
89 | % line.rstrip()) |
|
89 | logfn('# Not killing daemon process %s - invalid pid' | |
90 | continue |
|
90 | % line.rstrip()) | |
|
91 | continue | |||
|
92 | pids.append(pid) | |||
|
93 | for pid in pids: | |||
91 | kill(pid, logfn, tryhard) |
|
94 | kill(pid, logfn, tryhard) | |
92 | fp.close() |
|
|||
93 | if remove: |
|
95 | if remove: | |
94 | os.unlink(pidfile) |
|
96 | os.unlink(pidfile) | |
95 | except IOError: |
|
97 | except IOError: |
General Comments 0
You need to be logged in to leave comments.
Login now