Top | ![]() |
![]() |
![]() |
![]() |
pid_t | Tubo_fork () |
pid_t | Tubo_exec () |
pid_t | Tubo_threads () |
int | Tubo_controller () |
int | Tubo_child () |
unsigned | Tubo_get_id () |
unsigned | Tubo_id () |
#define | TUBO_CONTROLLER_PID |
#define | TUBO_EXIT_TEXT |
#define | TUBO_REAP_CHILD |
#define | TUBO_VALID_ANSI |
The functionality is similar to the glib function g_spawn_async_with_pipes()
except that all pipe setup and monitoring is taken care of. The calling function only has to provide the functions with which to process the input/output of the remote process. Furthermore, process control is done by individual threads controlled by semaphores, conditions and shared memory, which allows for control and response on multicore processors.
pid_t Tubo_fork (void (*fork_function) (void *)
,void *fork_function_data
,int *stdin_fd
,void (*stdout_f) (void *stdout_data, void *stream, int childFD)
,void (*stderr_f) (void *stderr_data, void *stream, int childFD)
,void (*tubo_done_f) (void *)
,void *user_function_data
,int flags
);
fork_function |
pointer to function to execute after forking. This will execute in the child process, and upon termination will be reaped by the controller process. |
|
fork_function_data |
pointer to data to be sent to |
|
stdin_fd |
pointer for file descriptor for stdin, or NULL |
|
stdout_f |
pointer to thread safe function to process stdout, or NULL. This
is executed by an independent thread. Please note that gtk or qt instructions
should be done via main thread, as with |
|
stderr_f |
pointer to thread safe function to process stderr, or NULL .This
is executed by an independent thread. Please note that gtk or qt instructions
should be done via main thread, as with |
|
tubo_done_f |
pointer to function to execute when remote process has terminated. Execution of this function does not mean all pipe data has been processed yet (data may still be flowing in the pipes). It just means that the spawned process has exited. |
|
user_function_data |
pointer to data to be sent to |
|
flags |
TUBO_EXIT_TEXT, print a process termination text at the end of
stdout. TUBO_REAP_CHILD, flag to reap child. Set to TRUE to have the
controller process reaped. If this is not set to, then the user is
responsible to reap the controller process (i.e., with |
pid of the program (not the controller). To obtain the controller
pid use Tubo_controller()
with the pid of the program as first argument.
This function is not available in systems without fork()
(i.e. windoze).
pid_t Tubo_exec (char **argv
,int *stdin_fd
,void (*stdout_f) (void *stdout_data, void *stream, int childFD)
,void (*stderr_f) (void *stderr_data, void *stream, int childFD)
,void (*tubo_done_f) (void *)
,void *user_function_data
,int flags
);
argv |
NULL terminated string vector with the arguments of the program to
be executed. This function uses |
|
stdin_fd |
pointer for file descriptor for stdin, or NULL |
|
stdout_f |
pointer to thread safe function to process stdout, or NULL. This
is executed by an independent thread. Please note that gtk or qt instructions
should be done via main thread, as with |
|
stderr_f |
pointer to thread safe function to process stderr, or NULL .This
is executed by an independent thread. Please note that gtk or qt instructions
should be done via main thread, as with |
|
tubo_done_f |
pointer to function to execute when remote process has terminated. Execution of this function does not mean all pipe data has been processed yet (data may still be flowing in the pipes). It just means that the spawned process has exited. |
|
user_function_data |
pointer to data to be sent to |
|
flags |
TUBO_EXIT_TEXT, print a process termination text at the end of
stdout. TUBO_REAP_CHILD, flag to reap child. Set to TRUE to have the
controller process reaped. If this is not set to, then the user is
responsible to reap the controller process (i.e., with |
pid of the program (not the controller). To obtain the controller
pid use Tubo_controller()
with the pid of the program as first argument.
This function is available in Linux, BSD and Windows.
pid_t Tubo_threads (void (*fork_function) (void *)
,void *fork_function_data
,int *stdin_fd
,void (*stdout_f) (void *stdout_data, void *stream, int childFD)
,void (*stderr_f) (void *stderr_data, void *stream, int childFD)
,void (*tubo_done_f) (void *)
,void *user_function_data
,int reap_child
,int check_valid_ansi_sequence
);
Tubo_threads
is deprecated and should not be used in newly-written code.
Use Tubo_fork()
or Tubo_exec()
instead
fork_function |
pointer to function to execute after forking. This will execute in the child process, and upon termination will be reaped by the controller process. |
|
fork_function_data |
pointer to data to be sent to |
|
stdin_fd |
pointer for file descriptor for stdin, or NULL |
|
stdout_f |
pointer to thread safe function to process stdout, or NULL. This
is executed by an independent thread. Please note that gtk or qt instructions
should be done via main thread, as with |
|
stderr_f |
pointer to thread safe function to process stderr, or NULL .This
is executed by an independent thread. Please note that gtk or qt instructions
should be done via main thread, as with |
|
tubo_done_f |
pointer to function to execute when remote process has terminated. Execution of this function does not mean all pipe data has been processed yet (data may still be flowing in the pipes). It just means that the spawned process has exited. |
|
user_function_data |
pointer to data to be sent to |
pid of controller process. This pid is not the pid of the program
being executed. It is a process that ensures pipes will remain open while
pipe output is still to be read. To send a TERM signal to the actual
process which is executing the remote command, send a USR1 signal to the
controller process. To send a KILL to the actual process which is executing
the remote command, send a USR1 signal to the controller process. Finer
signalling requires the use of Tubo_child()
function.
int
Tubo_child (pid_t controller
);
controller |
pid of the controller process. This pid is not the pid of the program being executed. It is the pid of the controller process. |
pid of program being executed. This pid may be used to signal
directly to the process, instead of the limited SIGUSR1 and SIGUSR2
described in Tubo_threads()
. Signals are currently not available in Windows.
#define TUBO_CONTROLLER_PID 0x08
Use this flag to have Tubo_exec()
and Tubo_fork()
return the controller
pid instead of the pid of the program being executed. This is the default
in Tubo_threads()
.
#define TUBO_EXIT_TEXT 0x04
Use this flag to have the controller print the standard "Tubo exit"
text to stdout on program termination. This is the default in
Tubo_threads()
.
#define TUBO_REAP_CHILD 0x01
Flag to do reap child process on termination. If this is not set, calling program is responsible for reaping the child process.