Increase log information when a RootHelperProcess fails
If a RootHelperProcess does not start, add more information to the exception raised: the command return code, the stdout and the stderr. Change-Id: I229e926341c5e6c8b06f59950e3ae09864d0f1f6 Closes-Bug: #1861221
This commit is contained in:
parent
520f7cb4a0
commit
97773eaea6
@ -327,11 +327,25 @@ class RootHelperProcess(subprocess.Popen):
|
|||||||
if utils.pid_invoked_with_cmdline(child_pid, self.cmd):
|
if utils.pid_invoked_with_cmdline(child_pid, self.cmd):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
common_utils.wait_until_true(
|
try:
|
||||||
child_is_running,
|
common_utils.wait_until_true(child_is_running, timeout)
|
||||||
timeout,
|
except common_utils.WaitTimeout:
|
||||||
exception=RuntimeError("Process %s hasn't been spawned "
|
# If there is an error, the stderr and stdout pipes usually have
|
||||||
"in %d seconds" % (self.cmd, timeout)))
|
# information returned by the command executed. If not, timeout
|
||||||
|
# the pipe communication quickly.
|
||||||
|
stdout = stderr = ''
|
||||||
|
try:
|
||||||
|
stdout, stderr = self.communicate(timeout=0.5)
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
pass
|
||||||
|
msg = ("Process %(cmd)s hasn't been spawned in %(seconds)d "
|
||||||
|
"seconds. Return code: %(ret_code)s, stdout: %(stdout)s, "
|
||||||
|
"sdterr: %(stderr)s" %
|
||||||
|
{'cmd': self.cmd, 'seconds': timeout,
|
||||||
|
'ret_code': self.returncode, 'stdout': stdout,
|
||||||
|
'stderr': stderr})
|
||||||
|
raise RuntimeError(msg)
|
||||||
|
|
||||||
self.child_pid = utils.get_root_helper_child_pid(
|
self.child_pid = utils.get_root_helper_child_pid(
|
||||||
self.pid, self.cmd, run_as_root=True)
|
self.pid, self.cmd, run_as_root=True)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user