:right-sidebar: True Pty =================================================================== .. currentmodule:: gi.repository.Vte .. class:: Pty(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gio.Initable` :Constructors: :: Pty(**properties) new_foreign_sync(fd:int, cancellable:Gio.Cancellable=None) -> Vte.Pty new_sync(flags:Vte.PtyFlags, cancellable:Gio.Cancellable=None) -> Vte.Pty Constructors ------------ .. rst-class:: interim-class .. class:: Pty :no-index: .. classmethod:: new_foreign_sync(fd: int, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Vte.Pty Creates a new :obj:`~gi.repository.Vte.Pty` for the PTY master ``fd``\. No entry will be made in the lastlog, utmp or wtmp system files. Note that the newly created :obj:`~gi.repository.Vte.Pty` will take ownership of ``fd`` and close it on finalize. :param fd: a file descriptor to the PTY :param cancellable: a :obj:`~gi.repository.Gio.Cancellable`\, or :const:`None` .. classmethod:: new_sync(flags: ~gi.repository.Vte.PtyFlags, cancellable: ~gi.repository.Gio.Cancellable | None = None) -> ~gi.repository.Vte.Pty Allocates a new pseudo-terminal. You can later use fork() or the :func:`~gi.repository.GLib.spawn_async` family of functions to start a process on the PTY. If using fork(), you MUST call :func:`~gi.repository.Vte.Pty.child_setup` in the child. If using :func:`~gi.repository.GLib.spawn_async` and friends, you MUST either use :func:`~gi.repository.Vte.Pty.child_setup` directly as the child setup function, or call :func:`~gi.repository.Vte.Pty.child_setup` from your own child setup function supplied. When using :func:`~gi.repository.Vte.Terminal.spawn_sync` with a custom child setup function, :func:`~gi.repository.Vte.Pty.child_setup` will be called before the supplied function; you must not call it again. Also, you MUST pass the %G_SPAWN_DO_NOT_REAP_CHILD flag. Note also that %G_SPAWN_STDOUT_TO_DEV_NULL, %G_SPAWN_STDERR_TO_DEV_NULL, and %G_SPAWN_CHILD_INHERITS_STDIN are not supported, since stdin, stdout and stderr of the child process will always be connected to the PTY. Note that you should set the PTY's size using :func:`~gi.repository.Vte.Pty.set_size` before spawning the child process, so that the child process has the correct size from the start instead of starting with a default size and then shortly afterwards receiving a ``SIGWINCH`` signal. You should prefer using :func:`~gi.repository.Vte.Terminal.pty_new_sync` which does this automatically. :param flags: flags from :obj:`~gi.repository.Vte.PtyFlags` :param cancellable: a :obj:`~gi.repository.Gio.Cancellable`\, or :const:`None` Methods ------- .. rst-class:: interim-class .. class:: Pty :no-index: .. method:: child_setup() -> None .. method:: close() -> None Since 0.42 this is a no-op. .. deprecated:: 0.42 Please do not use it in newly written code .. method:: get_fd() -> int .. method:: get_size() -> ~typing.Tuple[bool, int, int] Reads the pseudo terminal's window size. If getting the window size failed, ``error`` will be set to a :obj:`~gi.repository.GLib.IOError`\. .. method:: set_size(rows: int, columns: int) -> bool Attempts to resize the pseudo terminal's window size. If successful, the OS kernel will send ``SIGWINCH`` to the child process group. If setting the window size failed, ``error`` will be set to a :obj:`~gi.repository.GLib.IOError`\. :param rows: the desired number of rows :param columns: the desired number of columns .. method:: set_utf8(utf8: bool) -> bool Tells the kernel whether the terminal is UTF-8 or not, in case it can make use of the info. Linux 2.6.5 or so defines IUTF8 to make the line discipline do multibyte backspace correctly. :param utf8: whether or not the pty is in UTF-8 mode .. method:: spawn_async(working_directory: str | None, argv: list[str], envv: list[str] | None, spawn_flags: ~gi.repository.GLib.SpawnFlags, child_setup: ~typing.Callable[[~typing.Any], None] | None, timeout: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Like :func:`~gi.repository.Vte.Pty.spawn_with_fds_async`, except that this function does not allow passing file descriptors to the child process. See :func:`~gi.repository.Vte.Pty.spawn_with_fds_async` for more information. .. versionadded:: 0.48 :param working_directory: the name of a directory the command should start in, or :const:`None` to use the current working directory :param argv: child's argument vector :param envv: a list of environment variables to be added to the environment before starting the process, or :const:`None` :param spawn_flags: flags from :obj:`~gi.repository.GLib.SpawnFlags` :param child_setup: an extra child setup function to run in the child just before exec(), or :const:`None` :param timeout: a timeout value in ms, -1 for the default timeout, or G_MAXINT to wait indefinitely :param cancellable: a :obj:`~gi.repository.Gio.Cancellable`\, or :const:`None` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback`\, or :const:`None` :param user_data: user data for ``callback`` .. method:: spawn_finish(result: ~gi.repository.Gio.AsyncResult) -> ~typing.Tuple[bool, int] .. versionadded:: 0.48 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: spawn_with_fds_async(working_directory: str | None, argv: list[str], envv: list[str] | None, fds: list[int] | None, map_fds: list[int] | None, spawn_flags: ~gi.repository.GLib.SpawnFlags, child_setup: ~typing.Callable[[~typing.Any], None] | None, timeout: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Starts the specified command under the pseudo-terminal ``pty``\. The ``argv`` and ``envv`` lists should be :const:`None`-terminated. The "TERM" environment variable is automatically set to a default value, but can be overridden from ``envv``\. ``pty_flags`` controls logging the session to the specified system log files. Note also that %G_SPAWN_STDOUT_TO_DEV_NULL, %G_SPAWN_STDERR_TO_DEV_NULL, and %G_SPAWN_CHILD_INHERITS_STDIN are not supported in ``spawn_flags``\, since stdin, stdout and stderr of the child process will always be connected to the PTY. Also %G_SPAWN_LEAVE_DESCRIPTORS_OPEN is not supported; and %G_SPAWN_DO_NOT_REAP_CHILD will always be added to ``spawn_flags``\. If ``fds`` is not :const:`None`, the child process will map the file descriptors from ``fds`` according to ``map_fds``\; ``n_map_fds`` must be less or equal to ``n_fds``\. This function will take ownership of the file descriptors in ``fds``\; you must not use or close them after this call. All file descriptors in ``fds`` must have the FD_CLOEXEC flag set on them; it will be unset in the child process before calling man:execve(2). Note also that no file descriptor may be mapped to stdin, stdout, or stderr (file descriptors 0, 1, or 2), since these will be assigned to the PTY. All open file descriptors apart from those mapped as above will be closed when execve() is called. Beginning with 0.60, and on linux only, and unless :const:`~gi.repository.Vte.SPAWN_NO_SYSTEMD_SCOPE` is passed in ``spawn_flags``\, the newly created child process will be moved to its own systemd user scope; and if :const:`~gi.repository.Vte.SPAWN_REQUIRE_SYSTEMD_SCOPE` is passed, and creation of the systemd user scope fails, the whole spawn will fail. You can override the options used for the systemd user scope by providing a systemd override file for 'vte-spawn-.scope' unit. See man:systemd.unit(5) for further information. See vte_pty_new(), and :func:`~gi.repository.Vte.Terminal.watch_child` for more information. .. versionadded:: 0.62 :param working_directory: the name of a directory the command should start in, or :const:`None` to use the current working directory :param argv: child's argument vector :param envv: a list of environment variables to be added to the environment before starting the process, or :const:`None` :param fds: an array of file descriptors, or :const:`None` :param map_fds: an array of integers, or :const:`None` :param spawn_flags: flags from :obj:`~gi.repository.GLib.SpawnFlags` :param child_setup: an extra child setup function to run in the child just before exec(), or :const:`None` :param timeout: a timeout value in ms, -1 for the default timeout, or G_MAXINT to wait indefinitely :param cancellable: a :obj:`~gi.repository.Gio.Cancellable`\, or :const:`None` :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback`\, or :const:`None` :param user_data: user data for ``callback`` Properties ---------- .. rst-class:: interim-class .. class:: Pty :no-index: .. attribute:: props.fd :type: int The type of the None singleton. .. attribute:: props.flags :type: ~gi.repository.Vte.PtyFlags The type of the None singleton.