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

Function fork

Lib/pty.py:61–87  ·  view source on GitHub ↗

fork() -> (pid, master_fd) Fork and make the child a session leader with a controlling terminal.

()

Source from the content-addressed store, hash-verified

59
60
61def fork():
62 """fork() -> (pid, master_fd)
63 Fork and make the child a session leader with a controlling terminal."""
64
65 try:
66 pid, fd = os.forkpty()
67 except (AttributeError, OSError):
68 pass
69 else:
70 if pid == CHILD:
71 try:
72 os.setsid()
73 except OSError:
74 # os.forkpty() already set us session leader
75 pass
76 return pid, fd
77
78 master_fd, slave_fd = openpty()
79 pid = os.fork()
80 if pid == CHILD:
81 os.close(master_fd)
82 os.login_tty(slave_fd)
83 else:
84 os.close(slave_fd)
85
86 # Parent and child process.
87 return pid, master_fd
88
89def _read(fd):
90 """Default read function."""

Callers 2

_spawnvefFunction · 0.85
spawnFunction · 0.85

Calls 2

openptyFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…