MCPcopy Index your code
hub / github.com/python/cpython / spawn

Function spawn

Lib/pty.py:158–182  ·  view source on GitHub ↗

Create a spawned process.

(argv, master_read=_read, stdin_read=_read)

Source from the content-addressed store, hash-verified

156 i_buf += data
157
158def spawn(argv, master_read=_read, stdin_read=_read):
159 """Create a spawned process."""
160 if isinstance(argv, str):
161 argv = (argv,)
162 sys.audit('pty.spawn', argv)
163
164 pid, master_fd = fork()
165 if pid == CHILD:
166 os.execlp(argv[0], *argv)
167
168 try:
169 mode = tcgetattr(STDIN_FILENO)
170 setraw(STDIN_FILENO)
171 restore = True
172 except tty.error: # This is the same as termios.error
173 restore = False
174
175 try:
176 _copy(master_fd, master_read, stdin_read)
177 finally:
178 if restore:
179 tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode)
180
181 close(master_fd)
182 return waitpid(pid, 0)[1]

Callers 1

_test_invalid_envMethod · 0.85

Calls 6

setrawFunction · 0.90
forkFunction · 0.85
tcgetattrFunction · 0.85
_copyFunction · 0.85
tcsetattrFunction · 0.85
closeFunction · 0.70

Tested by 1

_test_invalid_envMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…