Create a spawned process.
(argv, master_read=_read, stdin_read=_read)
| 156 | i_buf += data |
| 157 | |
| 158 | def 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] |
searching dependent graphs…