def _handle_execute(execute_file, execute_args, stdin_file, stdout_file, stderr_file, extra_file, cgroup_file): pid = fork() if not pid: chdir('/in/package') if stdin_file: fd = os_open(stdin_file, O_RDONLY) dup2(fd, STDIN_FILENO) os_close(fd) if stdout_file: fd = os_open(stdout_file, O_WRONLY) dup2(fd, STDOUT_FILENO) os_close(fd) if stderr_file: fd = os_open(stderr_file, O_WRONLY) dup2(fd, STDERR_FILENO) os_close(fd) if extra_file: fd = os_open(extra_file, O_RDONLY) if fd == EXTRA_FILENO: set_inheritable(fd, True) else: dup2(fd, EXTRA_FILENO) os_close(fd) if cgroup_file: enter_cgroup(cgroup_file) execve(execute_file, execute_args, SPAWN_ENV) return wait_and_reap_zombies(pid)
def do_build(self, stdin_file, stdout_file, stderr_file, cgroup_file): pid = fork() if not pid: chdir('/out') if stdin_file: dup2(os_open(stdin_file, O_RDONLY), STDIN_FILENO) if stdout_file: dup2(os_open(stdout_file, O_WRONLY), STDOUT_FILENO) if stderr_file: dup2(os_open(stderr_file, O_WRONLY), STDERR_FILENO) if cgroup_file: enter_cgroup(cgroup_file) execve(self.compiler_file, self.compiler_args, SPAWN_ENV) return wait_and_reap_zombies(pid)
def _handle_compile(compiler_file, compiler_args, output_file, cgroup_file): pid = fork() if not pid: chdir('/out') os_close(STDIN_FILENO) if output_file: fd = os_open(output_file, O_WRONLY) dup2(fd, STDOUT_FILENO) dup2(fd, STDERR_FILENO) os_close(fd) if cgroup_file: enter_cgroup(cgroup_file) execve(compiler_file, compiler_args, SPAWN_ENV) return wait_and_reap_zombies(pid)
def do_execute(self, stdin_file, stdout_file, stderr_file, cgroup_file): pid = fork() if not pid: chdir('/in/package') if stdin_file: fd = os_open(stdin_file, O_RDONLY) dup2(fd, STDIN_FILENO) os_close(fd) if stdout_file: fd = os_open(stdout_file, O_WRONLY) dup2(fd, STDOUT_FILENO) os_close(fd) if stderr_file: fd = os_open(stderr_file, O_WRONLY) dup2(fd, STDERR_FILENO) os_close(fd) if cgroup_file: enter_cgroup(cgroup_file) execve(self.execute_file, self.execute_args, SPAWN_ENV) return wait_and_reap_zombies(pid)