Exemple #1
0
 def kill_subprocesses(
     self, name=None, sig=signal.SIGKILL, expected_num_killed=None
 ):
     # Kill all subprocesses
     proc_ids = utils.find_proc_id(proc_name=name, children_only=True)
     if expected_num_killed is not None:
         self.assertEqual(
             len(proc_ids),
             expected_num_killed,
             msg="Expected to find %d processes to kill, found %d"
             % (expected_num_killed, len(proc_ids)),
         )
     for proc_id in proc_ids:
         try:
             os.kill(proc_id, sig)
         except OSError:
             pass
Exemple #2
0
def _signal_handler(signum, _):
    name = "Unknown"
    for signame in _iter_signal_names():
        if signum == getattr(signal, signame):
            name = signame

    # Terminate children
    proc_ids = find_proc_id(children_only=True)
    for proc_id in proc_ids:
        try:
            os.kill(proc_id, signal.SIGKILL)
        except OSError:
            # If the batch system killed the entire process group, these
            # processes might already be dying
            pass

    # Throw an exception so SystemTest infrastructure can handle this error
    expect(False, "Job killed due to receiving signal %d (%s)" % (signum, name))
Exemple #3
0
def _signal_handler(signum, _):
    name = "Unknown"
    for signame in _iter_signal_names():
        if signum == getattr(signal, signame):
            name = signame

    # Terminate children
    proc_ids = find_proc_id(children_only=True)
    for proc_id in proc_ids:
        try:
            os.kill(proc_id, signal.SIGKILL)
        except OSError:
            # If the batch system killed the entire process group, these
            # processes might already be dying
            pass

    # Throw an exception so SystemTest infrastructure can handle this error
    expect(False, "Job killed due to receiving signal {:d} ({})".format(signum, name))