Top | ![]() |
![]() |
![]() |
![]() |
A GvaProcess provides a convenient interface for communicating with a child process through pipes.
GvaProcess * gva_process_new (GPid pid
,gint priority
,gint standard_input
,gint standard_output
,gint standard_error
);
Creates a new GvaProcess from the given parameters. A GSource is
created at the given priority
for each of the file descriptors. The
internal progress value is initialized to zero.
GvaProcess * gva_process_spawn (const gchar *command_line
,gint priority
,GError **error
);
Spawns a child process with command_line
and returns the resulting
GvaProcess. If an error occurs while spawning, the function returns
NULL
and sets error
.
GPid
gva_process_get_pid (GvaProcess *process
);
Returns the process ID for process
.
gboolean gva_process_write_stdin (GvaProcess *process
,const gchar *data
,gssize length
,GError **error
);
Writes data
to the stdin pipe of a child process represented by process
.
If an error occurs, it returns FALSE
and sets error
.
guint
gva_process_stdout_num_lines (GvaProcess *process
);
Returns the number of lines available for reading from the stdout pipe
of the child process represented by process
.
guint
gva_process_stderr_num_lines (GvaProcess *process
);
Returns the number of lines available for reading from the stderr pipe
of the child process represented by process
.
gchar *
gva_process_stdout_read_line (GvaProcess *process
);
Reads a line from the stdout pipe of the child process represented by
process
. This function does not block; it returns NULL
if no lines
are available. Use gva_process_stdout_num_lines()
to peek at whether
any lines are available. The line should be freed with g_free()
when
no longer needed.
gchar *
gva_process_stderr_read_line (GvaProcess *process
);
Reads a line from the stderr pipe of the child process represented by
process
. This function does not block; it returns NULL
if no lines
are available. Use gva_process_stderr_num_lines()
to peek at whether
any lines are available. The line should be freed with g_free()
when
no longer needed.
gchar **
gva_process_stdout_read_lines (GvaProcess *process
);
Returns a NULL
-terminated array of lines from the stdout pipe of the
child process represented by process
. This function does not block;
it returns NULL
if no lines are available. Use
gva_process_stdout_num_lines()
to peek at the number of lines available.
The array should be freed with g_strfreev()
when no longer needed.
gchar **
gva_process_stderr_read_lines (GvaProcess *process
);
Returns a NULL
-terminated array of lines from the stderr pipe of the
child process represented by process
. This function does not block;
it returns NULL
if no lines are available. Use
gva_process_stderr_num_lines()
to peek at the number of lines available.
The array should be freed with g_strfreev()
when no longer needed.
guint
gva_process_get_progress (GvaProcess *process
);
Returns the current progress value for process
. It is up to the
application to set this value using gva_process_set_progress()
or
gva_process_inc_progress()
.
void
gva_process_inc_progress (GvaProcess *process
);
Increments the progress value for process
. The progress value is
just a counter; it is up to the application to establish an upper
bound for the value.
void gva_process_set_progress (GvaProcess *process
,guint progress
);
Sets the progress value for process
. The progress value is just a
counter; it is up to the application to establish an upper bound for
the value.
gboolean gva_process_has_exited (GvaProcess *process
,gint *status
);
Returns TRUE
if the child process represented by process
has exited
and writes the exit status to the location pointed to by status
, if
status
is non-NULL
. There may still be lines available for reading
even after the child process has exited.
void
gva_process_kill (GvaProcess *process
);
Kills the child process represented by process
by sending it a
"kill" signal.
void
gva_process_kill_all (void
);
Kills all active child processes represented by GvaProcess instances by sending them "kill" signals.
void gva_process_get_time_elapsed (GvaProcess *process
,GTimeVal *time_elapsed
);
Writes the time elapsed since process
(the GvaProcess instance, not
necessarily the child process it represents) was created to time_elapsed
.
“pid”
property“pid” guint
The ID of the child process.
Owner: GvaProcess
Flags: Read / Write / Construct Only
Default value: 0
“priority”
property “priority” int
Priority of the event sources that watch for incoming data.
Owner: GvaProcess
Flags: Read / Write / Construct Only
Default value: 200
“progress”
property“progress” guint
Progress value, the meaning of which is defined by the application.
Owner: GvaProcess
Flags: Read / Write
Default value: 0
“stderr”
property “stderr” int
The file descriptor for the child process' stderr pipe.
Owner: GvaProcess
Flags: Read / Write / Construct Only
Allowed values: >= -1
Default value: -1
“stdin”
property “stdin” int
The file descriptor for the child process' stdin pipe.
Owner: GvaProcess
Flags: Read / Write / Construct Only
Allowed values: >= -1
Default value: -1
“exited”
signalvoid user_function (GvaProcess *process, int status, gpointer user_data)
The ::exited signal is emitted when the child process exits.
process |
the GvaProcess that received the signal |
|
status |
the exit status of the child process |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“stderr-ready”
signalvoid user_function (GvaProcess *process, gpointer user_data)
The ::stderr-ready signal is emitted when one or more lines from the child process' stderr pipe are available for reading.
process |
the GvaProcess that received the signal |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“stdout-ready”
signalvoid user_function (GvaProcess *process, gpointer user_data)
The ::stdout-ready signal is emitted when one or more lines from the child process' stdout pipe are available for reading.
process |
the GvaProcess that received the signal |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last