#include <stddef.h>
#include <signal.h>
Go to the source code of this file.
Functions | |
int | libcomcom_init (void) |
int | libcomcom_init2 (struct sigaction *old) |
int | libcomcom_init_stratum (void) |
int | libcomcom_run_command (const char *input, size_t input_len, const char **output, size_t *output_len, const char *file, char *const argv[], char *const envp[], int timeout) |
int | libcomcom_destroy (void) |
int | libcomcom_terminate (void) |
int | libcomcom_set_default_terminate (void) |
int | libcomcom_reset_default_terminate (void) |
int | libcomcom_set_default_terminate2 (void) |
int | libcomcom_reset_default_terminate2 (void) |
int libcomcom_destroy | ( | void | ) |
Should be run for normal termination (not in SIGTERM/SIGINT handler) of our program.
errno
). int libcomcom_init | ( | void | ) |
Initialize the library. Call it before libcomcom_run_command(). Note that this erases the old SIGCHLD handler (if any).
errno
).You should usually also initialize SIGTERM/SIGINT signal handlers.
int libcomcom_init2 | ( | struct sigaction * | 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.
errno
).You should usually also initialize SIGTERM/SIGINT signal handlers.
int libcomcom_init_stratum | ( | void | ) |
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).
WARNING: If before calling this SIGCHLD handler was set by signal() (not by sigaction()), then this function may not work (leads to undefined behavior) on some non-Unix systems.
errno
).You should usually also initialize SIGTERM/SIGINT signal handlers.
int libcomcom_reset_default_terminate | ( | void | ) |
Uninstall SIGTERM and SIGINT handler which calls libcomcom_terminate().
errno
).You are recommended to use libcomcom_reset_default_terminate2() instead.
int libcomcom_reset_default_terminate2 | ( | void | ) |
Resets to signal handlers which were before calling libcomcom_set_default_terminate2().
errno
). int libcomcom_run_command | ( | const char * | input, |
size_t | input_len, | ||
const char ** | output, | ||
size_t * | output_len, | ||
const char * | file, | ||
char *const | argv[], | ||
char *const | envp[], | ||
int | timeout | ||
) |
Runs an OS command.
input | passed to command stdin |
input_len | the length of the string passed to stdin |
output | at this location is stored the command's stdout (call free() after use) |
output_len | at this location is stored the length of command's stdout |
file | the command to run (PATH used) |
argv | arguments for the command to run |
envp | environment for the command to run (pass NULL to duplicate our environment) |
timeout | timeout in milliseconds, -1 means infinite timeout |
errno
). int libcomcom_set_default_terminate | ( | void | ) |
Install SIGTERM and SIGINT handler which calls libcomcom_terminate().
errno
).You are recommended to use libcomcom_set_default_terminate2() instead.
int libcomcom_set_default_terminate2 | ( | void | ) |
Install SIGTERM and SIGINT handler which calls libcomcom_terminate().
errno
).The installed signal handler also calls old signal handler automatically.
WARNING: If before calling these handlers were set by signal() (not by sigaction()), then this function may not work (leads to undefined behavior) on some non-Unix systems.
int libcomcom_terminate | ( | void | ) |
Usually should be run in SIGTERM and SIGINT handlers.
errno
).