libcomcom

Undocumented in source.

Members

Functions

libcomcom_destroy
int libcomcom_destroy()

Should be run for normal termination (not in SIGTERM/SIGINT handler) of our program. @return 0 on success and -1 on error (also sets errno).

libcomcom_init
int libcomcom_init()

Initialize the library. Call it before libcomcom_run_command(). Note that this erases the old SIGCHLD handler (if any). @return 0 on success and -1 on error (also sets errno).

libcomcom_init2
int libcomcom_init2(sigaction_t* old)

Initialize the library. Call it before libcomcom_run_command(). The old signal action is stored internally (and restored by libcomcom_destroy() or libcomcom_terminate()). The old signal handler (the one obtained from old variable) is also called from our SIGCHLD handler. @return 0 on success and -1 on error (also sets errno).

libcomcom_init_stratum
int libcomcom_init_stratum()

Initialize the library. Call it before libcomcom_run_command(). This function is like libcomcom_init2(), but the old SIGCHLD signal handler is obtained automatically (by sigaction() library function).

libcomcom_reset_default_terminate
int libcomcom_reset_default_terminate()

Uninstall SIGTERM and SIGINT handler which calls libcomcom_terminate(). @return 0 on success and -1 on error (also sets errno).

libcomcom_reset_default_terminate2
int libcomcom_reset_default_terminate2()

Resets to signal handlers which were before calling libcomcom_set_default_terminate2(). @return 0 on success and -1 on error (also sets errno).

libcomcom_run_command
int libcomcom_run_command(char* input, size_t input_len, char** output, size_t* output_len, char* file, char** argv, char** envp, int timeout)

Runs an OS command. @param input passed to command stdin @param input_len the length of the string passed to stdin @param output at this location is stored the command's stdout (call free() after use) @param output_len at this location is stored the length of command's stdout @param file the command to run (PATH used) @param argv arguments for the command to run @param envp environment for the command to run (pass NULL to duplicate our environment) @param timeout timeout in milliseconds, -1 means infinite timeout @return 0 on success and -1 on error (also sets errno).

libcomcom_set_default_terminate
int libcomcom_set_default_terminate()

Install SIGTERM and SIGINT handler which calls libcomcom_terminate(). @return 0 on success and -1 on error (also sets errno).

libcomcom_set_default_terminate2
int libcomcom_set_default_terminate2()

Install SIGTERM and SIGINT handler which calls libcomcom_terminate(). @return 0 on success and -1 on error (also sets errno).

libcomcom_terminate
int libcomcom_terminate()

Usually should be run in SIGTERM and SIGINT handlers. @return 0 on success and -1 on error (also sets errno).

Meta