Vte.Pty¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co/en |
|||
r/w/co/en |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Vte.Pty(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
- classmethod new_foreign_sync(fd, cancellable)¶
- Parameters:
fd (
int
) – a file descriptor to the PTYcancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
- Return type:
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:
flags (
Vte.PtyFlags
) – flags fromVte.PtyFlags
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
- Return type:
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 useVte.Pty.child_setup
() directly as the child setup function, or callVte.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
, andGLib.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 aSIGWINCH
signal. You should prefer usingVte.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:
- get_size()¶
- Raises:
- Returns:
- Return type:
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:
- Raises:
- Returns:
- Return type:
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:
- Returns:
- Return type:
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:
working_directory (
str
orNone
) – the name of a directory the command should start in, orNone
to use the current working directoryargv ([
str
]) – child’s argument vectorenvv ([
str
] orNone
) – a list of environment variables to be added to the environment before starting the process, orNone
spawn_flags (
GLib.SpawnFlags
) – flags fromGLib.SpawnFlags
child_setup (
GLib.SpawnChildSetupFunc
orNone
) – an extra child setup function to run in the child just before exec(), orNone
timeout (
int
) – a timeout value in ms, -1 for the default timeout, orGObject.G_MAXINT
to wait indefinitelycancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
, orNone
Like
Vte.Pty.spawn_with_fds_async
(), except that this function does not allow passing file descriptors to the child process. SeeVte.Pty.spawn_with_fds_async
() for more information.New in version 0.48.
- spawn_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
- Raises:
- Returns:
True
on success, orFalse
on error with error filled in- child_pid:
a location to store the child PID, or
None
- Return type:
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:
working_directory (
str
orNone
) – the name of a directory the command should start in, orNone
to use the current working directoryargv ([
str
]) – child’s argument vectorenvv ([
str
] orNone
) – a list of environment variables to be added to the environment before starting the process, orNone
spawn_flags (
GLib.SpawnFlags
) – flags fromGLib.SpawnFlags
child_setup (
GLib.SpawnChildSetupFunc
orNone
) – an extra child setup function to run in the child just before exec(), orNone
timeout (
int
) – a timeout value in ms, -1 for the default timeout, orGObject.G_MAXINT
to wait indefinitelycancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
, orNone
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
, andGLib.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. AlsoGLib.SpawnFlags.LEAVE_DESCRIPTORS_OPEN
is not supported; andGLib.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 ifVte.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:
- Default Value:
-1
- Flags:
The file descriptor of the PTY master.
- Vte.Pty.props.flags¶
- Name:
flags
- Type:
- Default Value:
- Flags:
Flags.