Execute program using os.posix_spawn().
(self, args, executable, env, restore_signals, close_fds,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite)
| 1837 | |
| 1838 | |
| 1839 | def _posix_spawn(self, args, executable, env, restore_signals, close_fds, |
| 1840 | p2cread, p2cwrite, |
| 1841 | c2pread, c2pwrite, |
| 1842 | errread, errwrite): |
| 1843 | """Execute program using os.posix_spawn().""" |
| 1844 | kwargs = {} |
| 1845 | if restore_signals: |
| 1846 | # See _Py_RestoreSignals() in Python/pylifecycle.c |
| 1847 | sigset = [] |
| 1848 | for signame in ('SIGPIPE', 'SIGXFZ', 'SIGXFSZ'): |
| 1849 | signum = getattr(signal, signame, None) |
| 1850 | if signum is not None: |
| 1851 | sigset.append(signum) |
| 1852 | kwargs['setsigdef'] = sigset |
| 1853 | |
| 1854 | file_actions = [] |
| 1855 | for fd in (p2cwrite, c2pread, errread): |
| 1856 | if fd != -1: |
| 1857 | file_actions.append((os.POSIX_SPAWN_CLOSE, fd)) |
| 1858 | for fd, fd2 in ( |
| 1859 | (p2cread, 0), |
| 1860 | (c2pwrite, 1), |
| 1861 | (errwrite, 2), |
| 1862 | ): |
| 1863 | if fd != -1: |
| 1864 | file_actions.append((os.POSIX_SPAWN_DUP2, fd, fd2)) |
| 1865 | |
| 1866 | if close_fds: |
| 1867 | file_actions.append((os.POSIX_SPAWN_CLOSEFROM, 3)) |
| 1868 | |
| 1869 | if file_actions: |
| 1870 | kwargs['file_actions'] = file_actions |
| 1871 | |
| 1872 | self.pid = os.posix_spawn(executable, args, env, **kwargs) |
| 1873 | self._child_created = True |
| 1874 | |
| 1875 | self._close_pipe_fds(p2cread, p2cwrite, |
| 1876 | c2pread, c2pwrite, |
| 1877 | errread, errwrite) |
| 1878 | |
| 1879 | def _execute_child(self, args, executable, preexec_fn, close_fds, |
| 1880 | pass_fds, cwd, env, |
no test coverage detected