BRL-CAD
|
Routines for launching and managing applications as subprocesses. More...
Files | |
file | process.h |
Enumerations | |
enum | bu_process_io_t { BU_PROCESS_STDIN , BU_PROCESS_STDOUT , BU_PROCESS_STDERR } |
Functions | |
int | bu_process_id (void) |
int | bu_terminate (int process) |
terminate a given process and any children. More... | |
FILE * | bu_process_open (struct bu_process *pinfo, bu_process_io_t d) |
void | bu_process_close (struct bu_process *pinfo, bu_process_io_t d) |
int | bu_process_fileno (struct bu_process *pinfo, bu_process_io_t d) |
int | bu_process_pid (struct bu_process *pinfo) |
int | bu_process_args (const char **cmd, const char *const **argv, struct bu_process *pinfo) |
int | bu_process_read (char *buff, int *count, struct bu_process *pinfo, bu_process_io_t d, int n) |
void | bu_process_exec (struct bu_process **info, const char *cmd, int argc, const char **argv, int out_eql_err, int hide_window) |
Wrapper for executing a sub-process. More... | |
int | bu_process_wait (int *aborted, struct bu_process *pinfo, int wtime) |
wait for a sub-process to complete, release all process allocations, and release the process itself. More... | |
int | bu_interactive (void) |
detect whether or not a program is being run in interactive mode More... | |
Routines for launching and managing applications as subprocesses.
Routines for process and sub-process management.
enum bu_process_io_t |
int bu_process_id | ( | void | ) |
returns the process ID of the calling process
int bu_terminate | ( | int | process | ) |
terminate a given process and any children.
returns truthfully whether the process could be killed.
FILE * bu_process_open | ( | struct bu_process * | pinfo, |
bu_process_io_t | d | ||
) |
Open and return a FILE pointer associated with the specified file descriptor for input (0), output (1), or error (2) respectively.
Input will be opened write, output and error will be opened read.
Caller should not close these FILE pointers directly. Call bu_process_close() instead.
FIXME: misnomer, this does not open a process. Probably doesn't need to exist; just call fdopen().
void bu_process_close | ( | struct bu_process * | pinfo, |
bu_process_io_t | d | ||
) |
Close any FILE pointers internally opened via bu_process_open().
FIXME: misnomer, this does not close a process. Probably doesn't need to exist; just call fclose().
int bu_process_fileno | ( | struct bu_process * | pinfo, |
bu_process_io_t | d | ||
) |
Retrieve the file descriptor to the input (BU_PROCESS_STDIN), output (BU_PROCESS_STDOUT), or error (BU_PROCESS_STDERR) I/O channel associated with the process.
For Windows cases where HANDLE is needed, use _get_osfhandle
int bu_process_pid | ( | struct bu_process * | pinfo | ) |
Return the pid of the subprocess.
FIXME: seemingly redundant or combinable with bu_process_id() (perhaps make NULL be equivalent to the current process).
int bu_process_args | ( | const char ** | cmd, |
const char *const ** | argv, | ||
struct bu_process * | pinfo | ||
) |
Reports one or both of the command string and the argv array used to execute the process.
The bu_process container owns all strings for both cmd and argv - for the caller they are read-only.
If either cmd or argv are NULL they will be skipped - if the caller only wants one of these outputs the other argument can be set to NULL.
[out] | cmd | - pointer to the cmd string used to launch pinfo |
[out] | argv | - pointer to the argv array used to launch pinfo |
[in] | pinfo | - the bu_process structure of interest |
int bu_process_read | ( | char * | buff, |
int * | count, | ||
struct bu_process * | pinfo, | ||
bu_process_io_t | d, | ||
int | n | ||
) |
Read up to n bytes into buff from a process's specified output channel (fd == 1 for output, fd == 2 for err).
FIXME: arg ordering and input/output grouping is wrong. partially redundant with bu_process_fd() and/or bu_process_open().
void bu_process_exec | ( | struct bu_process ** | info, |
const char * | cmd, | ||
int | argc, | ||
const char ** | argv, | ||
int | out_eql_err, | ||
int | hide_window | ||
) |
Wrapper for executing a sub-process.
FIXME: eliminate the last two options so all callers are not exposed to parameters not relevant to them.
int bu_process_wait | ( | int * | aborted, |
struct bu_process * | pinfo, | ||
int | wtime | ||
) |
wait for a sub-process to complete, release all process allocations, and release the process itself.
FIXME: 'aborted' argument may be unnecessary (could make function provide return value of the process waited for). wtime undocumented.
int bu_interactive | ( | void | ) |
detect whether or not a program is being run in interactive mode
Returns 1 if interactive, else 0