Bug 931078 - add ability to pass signal to dm.killProcess, r=wlach

This commit is contained in:
Andrew Halberstadt 2013-10-28 11:43:39 -04:00
parent 98ac5d8f72
commit 547119fc65
3 changed files with 12 additions and 9 deletions

View File

@ -419,10 +419,13 @@ class DeviceManager(object):
@abstractmethod
def killProcess(self, processName, forceKill=False):
def killProcess(self, processName, sig=None):
"""
Kills the process named processName. If forceKill is True, process is
killed regardless of state.
Kills the process named processName. If sig is not None, process is
killed with the specified signal.
:param processName: path or name of the process to kill
:param sig: signal to pass into the kill command (optional)
"""
@abstractmethod

View File

@ -374,13 +374,13 @@ class DeviceManagerADB(DeviceManager):
self._checkCmd(acmd)
return outputFile
def killProcess(self, appname, forceKill=False):
def killProcess(self, appname, sig=None):
procs = self.getProcessList()
for (pid, name, user) in procs:
if name == appname:
args = ["shell", "kill"]
if forceKill:
args.append("-9")
if sig:
args.append("-%d" % sig)
args.append(str(pid))
p = self._runCmdAs(args)
p.communicate()

View File

@ -525,9 +525,9 @@ class DeviceManagerSUT(DeviceManager):
self.fireProcess(cmdline, failIfRunning)
return outputFile
def killProcess(self, appname, forceKill=False):
if forceKill:
self._logger.warn("killProcess(): forceKill parameter unsupported on SUT")
def killProcess(self, appname, sig=None):
if sig:
self._logger.warn("killProcess(): sig parameter unsupported on SUT")
retries = 0
while retries < self.retryLimit:
try: