Revision fee80e90
b/lib/utils.py | ||
---|---|---|
290 | 290 |
return alive |
291 | 291 |
|
292 | 292 |
|
293 |
def IsPidFileAlive(pidfile): |
|
294 |
"""Check whether the given pidfile points to a live process. |
|
295 |
|
|
296 |
@param pidfile: Path to a file containing the pid to be checked |
|
297 |
@type pidfile: string (filename) |
|
298 |
|
|
299 |
""" |
|
300 |
try: |
|
301 |
pf = open(pidfile, 'r') |
|
302 |
except EnvironmentError, open_err: |
|
303 |
if open_err.errno == errno.ENOENT: |
|
304 |
return False |
|
305 |
else: |
|
306 |
raise errors.GenericError("Cannot open file %s. Error: %s" % |
|
307 |
(pidfile, str(open_err))) |
|
308 |
|
|
309 |
try: |
|
310 |
pid = int(pf.read()) |
|
311 |
except ValueError: |
|
312 |
raise errors.GenericError("Invalid pid string in %s" % |
|
313 |
(pidfile,)) |
|
314 |
|
|
315 |
return IsProcessAlive(pid) |
|
316 |
|
|
317 |
|
|
293 | 318 |
def MatchNameComponent(key, name_list): |
294 | 319 |
"""Try to match a name against a list. |
295 | 320 |
|
Also available in: Unified diff