MCPcopy Index your code
hub / github.com/RustPython/RustPython / _posix_spawn

Method _posix_spawn

Lib/subprocess.py:1785–1823  ·  view source on GitHub ↗

Execute program using os.posix_spawn().

(self, args, executable, env, restore_signals, close_fds,
                         p2cread, p2cwrite,
                         c2pread, c2pwrite,
                         errread, errwrite)

Source from the content-addressed store, hash-verified

1783
1784
1785 def _posix_spawn(self, args, executable, env, restore_signals, close_fds,
1786 p2cread, p2cwrite,
1787 c2pread, c2pwrite,
1788 errread, errwrite):
1789 """Execute program using os.posix_spawn()."""
1790 kwargs = {}
1791 if restore_signals:
1792 # See _Py_RestoreSignals() in Python/pylifecycle.c
1793 sigset = []
1794 for signame in ('SIGPIPE', 'SIGXFZ', 'SIGXFSZ'):
1795 signum = getattr(signal, signame, None)
1796 if signum is not None:
1797 sigset.append(signum)
1798 kwargs['setsigdef'] = sigset
1799
1800 file_actions = []
1801 for fd in (p2cwrite, c2pread, errread):
1802 if fd != -1:
1803 file_actions.append((os.POSIX_SPAWN_CLOSE, fd))
1804 for fd, fd2 in (
1805 (p2cread, 0),
1806 (c2pwrite, 1),
1807 (errwrite, 2),
1808 ):
1809 if fd != -1:
1810 file_actions.append((os.POSIX_SPAWN_DUP2, fd, fd2))
1811
1812 if close_fds:
1813 file_actions.append((os.POSIX_SPAWN_CLOSEFROM, 3))
1814
1815 if file_actions:
1816 kwargs['file_actions'] = file_actions
1817
1818 self.pid = os.posix_spawn(executable, args, env, **kwargs)
1819 self._child_created = True
1820
1821 self._close_pipe_fds(p2cread, p2cwrite,
1822 c2pread, c2pwrite,
1823 errread, errwrite)
1824
1825 def _execute_child(self, args, executable, preexec_fn, close_fds,
1826 pass_fds, cwd, env,

Callers 1

_execute_childMethod · 0.95

Calls 3

_close_pipe_fdsMethod · 0.95
getattrFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected