Top | ![]() |
![]() |
![]() |
![]() |
Vte PTYVte PTY — Functions for starting a new process on a new pseudo-terminal and for manipulating pseudo-terminals |
VtePty * | vte_pty_new_sync () |
VtePty * | vte_pty_new_foreign_sync () |
void | vte_pty_child_setup () |
int | vte_pty_get_fd () |
gboolean | vte_pty_set_size () |
gboolean | vte_pty_get_size () |
gboolean | vte_pty_set_utf8 () |
void | vte_pty_spawn_async () |
gboolean | vte_pty_spawn_finish () |
void | vte_pty_close () |
The terminal widget uses these functions to start commands with new controlling pseudo-terminals and to resize pseudo-terminals.
VtePty * vte_pty_new_sync (VtePtyFlags flags
,GCancellable *cancellable
,GError **error
);
Allocates a new pseudo-terminal.
You can later use fork()
or the g_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 g_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 G_SPAWN_DO_NOT_REAP_CHILD
flag.
[constructor]
flags |
flags from VtePtyFlags |
|
cancellable |
a GCancellable, or |
[allow-none] |
error |
[allow-none] |
VtePty * vte_pty_new_foreign_sync (int fd
,GCancellable *cancellable
,GError **error
);
Creates a new VtePty for the PTY master fd
.
No entry will be made in the lastlog, utmp or wtmp system files.
Note that the newly created VtePty will take ownership of fd
and close it on finalize.
[constructor]
fd |
a file descriptor to the PTY. |
[transfer full] |
cancellable |
a GCancellable, or |
[allow-none] |
error |
[allow-none] |
gboolean vte_pty_set_size (VtePty *pty
,int rows
,int columns
,GError **error
);
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 GIOError.
gboolean vte_pty_get_size (VtePty *pty
,int *rows
,int *columns
,GError **error
);
Reads the pseudo terminal's window size.
If getting the window size failed, error
will be set to a GIOError.
gboolean vte_pty_set_utf8 (VtePty *pty
,gboolean utf8
,GError **error
);
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.
void vte_pty_spawn_async (VtePty *pty
,const char *working_directory
,char **argv
,char **envv
,GSpawnFlags spawn_flags
,GSpawnChildSetupFunc child_setup
,gpointer child_setup_data
,GDestroyNotify child_setup_data_destroy
,int timeout
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Starts the specified command under the pseudo-terminal pty
.
The argv
and envv
lists should be NULL
-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 that G_SPAWN_DO_NOT_REAP_CHILD
will always be added to spawn_flags
.
Note that all open file descriptors will be closed in the child. If you want to keep some file descriptor open for use in the child process, you need to use a child setup function that unsets the FD_CLOEXEC flag on that file descriptor.
See vte_pty_new()
, g_spawn_async()
and vte_terminal_watch_child()
for more information.
pty |
a VtePty |
|
working_directory |
the name of a directory the command should start
in, or |
[allow-none] |
argv |
child's argument vector. |
[array zero-terminated=1][element-type filename] |
envv |
a list of environment
variables to be added to the environment before starting the process, or |
[allow-none][array zero-terminated=1][element-type filename] |
spawn_flags |
flags from GSpawnFlags |
|
child_setup |
an extra child setup function to run in the child just before |
[allow-none][scope async] |
child_setup_data |
user data for |
[closure child_setup] |
child_setup_data_destroy |
a GDestroyNotify for |
[destroy child_setup_data] |
timeout |
a timeout value in ms, or -1 to wait indefinitely |
|
cancellable |
a GCancellable, or |
[allow-none] |
Since: 0.48
gboolean vte_pty_spawn_finish (VtePty *pty
,GAsyncResult *result
,GPid *child_pid
,GError **error
);
Since: 0.48
“fd”
property“fd” gint
The file descriptor of the PTY master.
Flags: Read / Write / Construct Only
Allowed values: >= -1
Default value: -1