# Path: opendiamond/helpers.py
# def signalname(signum):
#     '''Return the name for the specified signal number.'''
#     for attr in dir(signal):
#         if (attr.startswith('SIG') and not attr.startswith('SIG_') and
#                 getattr(signal, attr) == signum):
#             return attr
#     return 'signal %d' % signum


from builtins import range
from builtins import object
from tempfile import mkdtemp
from opendiamond.helpers import signalname
import logging
import os
import shutil
import signal
import sys
import time
                    with open(self._taskfile) as fh:
                        pids = [int(pid) for pid in fh
                                if int(pid) not in killed]
                    if not pids:
                        break
                    for pid in pids:
                        try:
                            os.kill(pid, signal.SIGKILL)
                        except OSError:
                            # Unable to signal process; perhaps it has
                            # already died
                            pass
                        killed.add(pid)
                for _i in range(3):
                    # rmdir has been seen to return "device or resource busy"
                    # or "interrupted system call".  The former can be
                    # returned when there are processes remaining in a cgroup,
                    # so this may indicate a race within the cgroup
                    # implementation.
                    try:
                        os.rmdir(self._cgroupdir)
                    except OSError:
                        time.sleep(0.01)
                    else:
                        break
                else:
                    # Leak an empty cgroup
                    _log.warning("Couldn't remove %s", self._cgroupdir)
                _log.info('PID %d exiting, killed %d processes',
                          self.pid, len(killed))

# Path: opendiamond/helpers.py
# def signalname(signum):
#     '''Return the name for the specified signal number.'''
#     for attr in dir(signal):
#         if (attr.startswith('SIG') and not attr.startswith('SIG_') and
#                 getattr(signal, attr) == signum):
#             return attr
#     return 'signal %d' % signum


# Path: opendiamond/server/child.py
from builtins import range
from builtins import object
from tempfile import mkdtemp
from opendiamond.helpers import signalname
import logging
import os
import shutil
import signal
import sys
import time

                    with open(self._taskfile) as fh:
                        pids = [int(pid) for pid in fh
                                if int(pid) not in killed]
                    if not pids:
                        break
                    for pid in pids:
                        try:
                            os.kill(pid, signal.SIGKILL)
                        except OSError:
                            # Unable to signal process; perhaps it has
                            # already died
                            pass
                        killed.add(pid)
                for _i in range(3):
                    # rmdir has been seen to return "device or resource busy"
                    # or "interrupted system call".  The former can be
                    # returned when there are processes remaining in a cgroup,
                    # so this may indicate a race within the cgroup
                    # implementation.
                    try:
                        os.rmdir(self._cgroupdir)
                    except OSError:
                        time.sleep(0.01)
                    else:
                        break
                else:
                    # Leak an empty cgroup
                    _log.warning("Couldn't remove %s", self._cgroupdir)
                _log.info('PID %d exiting, killed %d processes',
                          self.pid, len(killed))

            else: