Skip to content

gh-85984: Add POSIX pseudo-terminal functions. #102413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,19 @@ as internal buffering of data.
.. versionchanged:: 3.12
Added support for pipes on Windows.


.. function:: grantpt(fd, /)

Grant access to the slave pseudo-terminal device associated with the
master pseudo-terminal device to which the file descriptor *fd* refers.

Calls the C standard library function :c:func:`grantpt`.

.. availability:: Unix, not Emscripten, not WASI.

.. versionadded:: 3.13


.. function:: isatty(fd, /)

Return ``True`` if the file descriptor *fd* is open and connected to a
Expand Down Expand Up @@ -1429,6 +1442,19 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
.. versionadded:: 3.3


.. function:: posix_openpt(oflag, /)

Open and return a file descriptor for a master pseudo-terminal device.

Calls the C standard library function :c:func:`posix_openpt`. The *oflag*
argument is used to set file status flags and file access modes as
specified in the manual page of :c:func:`posix_openpt` of your system.

.. availability:: Unix, not Emscripten, not WASI.

.. versionadded:: 3.13


.. function:: preadv(fd, buffers, offset, flags=0, /)

Read from a file descriptor *fd* at a position of *offset* into mutable
Expand Down Expand Up @@ -1486,6 +1512,19 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
.. versionadded:: 3.7


.. function:: ptsname(fd, /)

Return the name of the slave pseudo-terminal device associated with the
master pseudo-terminal device to which the file descriptor *fd* refers.

Calls the C standard library function :c:func:`ptsname`, which is not
guaranteed to be thread-safe.

.. availability:: Unix, not Emscripten, not WASI.

.. versionadded:: 3.13


.. function:: pwrite(fd, str, offset, /)

Write the bytestring in *str* to file descriptor *fd* at position of
Expand Down Expand Up @@ -1738,6 +1777,18 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
.. availability:: Unix.


.. function:: unlockpt(fd, /)

Unlock the slave pseudo-terminal device associated with the master
pseudo-terminal device to which the file descriptor *fd* refers.

Calls the C standard library function :c:func:`unlockpt`.

.. availability:: Unix, not Emscripten, not WASI.

.. versionadded:: 3.13


.. function:: write(fd, str, /)

Write the bytestring in *str* to file descriptor *fd*.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add POSIX pseudo-terminal functions :func:`os.posix_openpt`,
:func:`os.grantpt`, :func:`os.unlockpt`, and :func:`os.ptsname`.
167 changes: 166 additions & 1 deletion Modules/clinic/posixmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading