mirror of
https://github.com/lutris/lutris
synced 2024-09-05 23:46:21 +00:00
Error catching in Process
This commit is contained in:
parent
dabd331d8f
commit
7afe720b50
|
@ -1,10 +1,18 @@
|
|||
import os
|
||||
import signal
|
||||
from lutris.util.log import logger
|
||||
|
||||
|
||||
class InvalidPid(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Process(object):
|
||||
def __init__(self, pid, parent=None):
|
||||
self.pid = pid
|
||||
try:
|
||||
self.pid = int(pid)
|
||||
except ValueError:
|
||||
raise InvalidPid("'%s' is not a valid pid" % pid)
|
||||
self.children = []
|
||||
self.parent = None
|
||||
self.get_children()
|
||||
|
@ -81,4 +89,7 @@ class Process(object):
|
|||
return os.readlink(cwd_path)
|
||||
|
||||
def kill(self):
|
||||
os.kill(self.pid, signal.SIGKILL)
|
||||
try:
|
||||
os.kill(self.pid, signal.SIGKILL)
|
||||
except OSError:
|
||||
logger.error("Could not kill process %s", self.pid)
|
||||
|
|
Loading…
Reference in a new issue