return output
-def do(command, shell=False, chrootPath=None, cwd=None, timeout=0, raiseExc=True, returnOutput=0, personality=None, logger=None, env=None, *args, **kargs):
+def do(command, shell=False, chrootPath=None, cwd=None, timeout=0, raiseExc=True, returnOutput=0, personality=None, logger=None, env=None, cgroup=None, *args, **kargs):
# Save the output of command
output = ""
logger.debug("Executing command: %s in %s" % (command, chrootPath or "/"))
try:
- child = None
-
# Create new child process
child = subprocess.Popen(
command,
env=env
)
+ # If cgroup is given, attach the subprocess.
+ if cgroup:
+ cgroup.attach_task(child.pid)
+
# use select() to poll for output so we dont block
output = logOutput([child.stdout, child.stderr], logger, returnOutput, start, timeout)