Ejemplo n.º 1
0
 def testIsChildProcess(self):
   """Test IsChildProcess with no name."""
   mock_pstree_output = 'a(1)-+-b(2)\n\t|-c(3)\n\t|-foo(4)-bar(5)'
   self.rc.AddCmdResult(partial_mock.Ignore(), output=mock_pstree_output)
   self.assertTrue(osutils.IsChildProcess(4))
   self.assertTrue(osutils.IsChildProcess(4, name='foo'))
   self.assertFalse(osutils.IsChildProcess(5, name='foo'))
Ejemplo n.º 2
0
 def _GetDDPid(self):
   """Get the Pid of dd."""
   try:
     pids = cros_build_lib.RunCommand(['pgrep', 'dd'], capture_output=True,
                                      print_cmd=False).output
     for pid in pids.splitlines():
       if osutils.IsChildProcess(int(pid), name='dd'):
         return int(pid)
     return -1
   except cros_build_lib.RunCommandError:
     # If dd isn't still running, then we assume that it is finished.
     return -1