Vte.Pty

g GObject.GInterface GObject.GInterface Gio.Initable Gio.Initable GObject.GInterface->Gio.Initable GObject.Object GObject.Object Vte.Pty Vte.Pty GObject.Object->Vte.Pty Gio.Initable->Vte.Pty

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.Initable (2)

Structs:

GObject.ObjectClass (5)

class

new_foreign_sync (fd, cancellable)

class

new_sync (flags, cancellable)

child_setup ()

close ()

get_fd ()

get_size ()

set_size (rows, columns)

set_utf8 (utf8)

spawn_async (working_directory, argv, envv, spawn_flags, child_setup, timeout, cancellable, callback, *user_data)

spawn_finish (result)

spawn_with_fds_async (working_directory, argv, envv, fds, map_fds, spawn_flags, child_setup, timeout, cancellable, callback, *user_data)

Virtual Methods

Inherited:

GObject.Object (7), Gio.Initable (1)

Properties

Name

Type

Flags

Short Description

fd

int

r/w/co/en

flags

Vte.PtyFlags

r/w/co/en

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Vte.Pty(**kwargs)
Bases:

GObject.Object, Gio.Initable

Abstract:

No

Structure:

Vte.PtyClass

classmethod new_foreign_sync(fd, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

a new Vte.Pty for fd, or None on error with error filled in

Return type:

Vte.Pty

Creates a new 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 Vte.Pty will take ownership of fd and close it on finalize.

classmethod new_sync(flags, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

a new Vte.Pty, or None on error with error filled in

Return type:

Vte.Pty

Allocates a new pseudo-terminal.

You can later use fork() or the GLib.spawn_async() family of functions to start a process on the PTY.

If using fork(), you MUST call Vte.Pty.child_setup() in the child.

If using GLib.spawn_async() and friends, you MUST either use Vte.Pty.child_setup() directly as the child setup function, or call Vte.Pty.child_setup() from your own child setup function supplied.

When using Vte.Terminal.spawn_sync() with a custom child setup function, Vte.Pty.child_setup() will be called before the supplied function; you must not call it again.

Also, you MUST pass the GLib.SpawnFlags.DO_NOT_REAP_CHILD flag.

Note also that GLib.SpawnFlags.STDOUT_TO_DEV_NULL, GLib.SpawnFlags.STDERR_TO_DEV_NULL, and GLib.SpawnFlags.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 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 Vte.Terminal.pty_new_sync() which does this automatically.

child_setup()
close()

Since 0.42 this is a no-op.

Deprecated since version 0.42.

get_fd()
Returns:

the file descriptor of the PTY master in self. The file descriptor belongs to self and must not be closed or have its flags changed

Return type:

int

get_size()
Raises:

GLib.Error

Returns:

True on success, False on failure with error filled in

rows:

a location to store the number of rows, or None

columns:

a location to store the number of columns, or None

Return type:

(bool, rows: int, columns: int)

Reads the pseudo terminal’s window size.

If getting the window size failed, error will be set to a GLib.IOError.

set_size(rows, columns)
Parameters:
  • rows (int) – the desired number of rows

  • columns (int) – the desired number of columns

Raises:

GLib.Error

Returns:

True on success, False on failure with error filled in

Return type:

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 GLib.IOError.

set_utf8(utf8)
Parameters:

utf8 (bool) – whether or not the pty is in UTF-8 mode

Raises:

GLib.Error

Returns:

True on success, False on failure with error filled in

Return type:

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.

spawn_async(working_directory, argv, envv, spawn_flags, child_setup, timeout, cancellable, callback, *user_data)
Parameters:

Like Vte.Pty.spawn_with_fds_async(), except that this function does not allow passing file descriptors to the child process. See Vte.Pty.spawn_with_fds_async() for more information.

New in version 0.48.

spawn_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True on success, or False on error with error filled in

child_pid:

a location to store the child PID, or None

Return type:

(bool, child_pid: int)

New in version 0.48.

spawn_with_fds_async(working_directory, argv, envv, fds, map_fds, spawn_flags, child_setup, timeout, cancellable, callback, *user_data)
Parameters:

Starts the specified command under the pseudo-terminal self. The argv and envv lists should be 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 GLib.SpawnFlags.STDOUT_TO_DEV_NULL, GLib.SpawnFlags.STDERR_TO_DEV_NULL, and GLib.SpawnFlags.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 GLib.SpawnFlags.LEAVE_DESCRIPTORS_OPEN is not supported; and GLib.SpawnFlags.DO_NOT_REAP_CHILD will always be added to spawn_flags.

If fds is not 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 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 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 Vte.Terminal.watch_child() for more information.

New in version 0.62.

Property Details

Vte.Pty.props.fd
Name:

fd

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

The file descriptor of the PTY master.

Vte.Pty.props.flags
Name:

flags

Type:

Vte.PtyFlags

Default Value:

Vte.PtyFlags.DEFAULT

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

Flags.