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

Function spawn

Lib/pty.py:187–211  ·  view source on GitHub ↗

Create a spawned process.

(argv, master_read=_read, stdin_read=_read)

Source from the content-addressed store, hash-verified

185 i_buf += data
186
187def spawn(argv, master_read=_read, stdin_read=_read):
188 """Create a spawned process."""
189 if isinstance(argv, str):
190 argv = (argv,)
191 sys.audit('pty.spawn', argv)
192
193 pid, master_fd = fork()
194 if pid == CHILD:
195 os.execlp(argv[0], *argv)
196
197 try:
198 mode = tcgetattr(STDIN_FILENO)
199 setraw(STDIN_FILENO)
200 restore = True
201 except tty.error: # This is the same as termios.error
202 restore = False
203
204 try:
205 _copy(master_fd, master_read, stdin_read)
206 finally:
207 if restore:
208 tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode)
209
210 close(master_fd)
211 return waitpid(pid, 0)[1]

Callers 1

_test_invalid_envMethod · 0.50

Calls 8

setrawFunction · 0.90
closeFunction · 0.90
waitpidFunction · 0.90
isinstanceFunction · 0.85
_copyFunction · 0.85
forkFunction · 0.70
tcgetattrFunction · 0.50
tcsetattrFunction · 0.50

Tested by 1

_test_invalid_envMethod · 0.40