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

Function openpty

Lib/pty.py:26–46  ·  view source on GitHub ↗

openpty() -> (master_fd, slave_fd) Open a pty master/slave pair, using os.openpty() if possible.

()

Source from the content-addressed store, hash-verified

24CHILD = 0
25
26def openpty():
27 """openpty() -> (master_fd, slave_fd)
28 Open a pty master/slave pair, using os.openpty() if possible."""
29
30 try:
31 return os.openpty()
32 except (AttributeError, OSError):
33 pass
34 master_fd, slave_name = _open_terminal()
35
36 slave_fd = os.open(slave_name, os.O_RDWR)
37 try:
38 from fcntl import ioctl, I_PUSH
39 except ImportError:
40 return master_fd, slave_fd
41 try:
42 ioctl(slave_fd, I_PUSH, "ptem")
43 ioctl(slave_fd, I_PUSH, "ldterm")
44 except OSError:
45 pass
46 return master_fd, slave_fd
47
48def _open_terminal():
49 """Open pty master and return (master_fd, tty_name)."""

Callers 2

src.mjsFile · 0.85
forkFunction · 0.85

Calls 3

_open_terminalFunction · 0.85
ioctlFunction · 0.85
openMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…