Low level process routines. More...
Data Structures | |
struct | GNUNET_OS_ProjectData |
Project-specific data used to help the OS subsystem find installation paths. More... | |
Macros | |
#define | HAVE_SYSCONF 0 |
#define | GNUNET_OS_get_hostname_max_length() 255 |
Get maximum string length returned by gethostname() More... | |
Typedefs | |
typedef enum GNUNET_GenericReturnValue(* | GNUNET_OS_NetworkInterfaceProcessor) (void *cls, const char *name, int isDefault, const struct sockaddr *addr, const struct sockaddr *broadcast_addr, const struct sockaddr *netmask, socklen_t addrlen) |
Callback function invoked for each interface found. More... | |
typedef void(* | GNUNET_OS_LineProcessor) (void *cls, const char *line) |
Type of a function to process a line of output. More... | |
Enumerations | |
enum | GNUNET_OS_InheritStdioFlags { GNUNET_OS_INHERIT_STD_NONE = 0 , GNUNET_OS_INHERIT_STD_IN = 1 , GNUNET_OS_INHERIT_STD_OUT = 2 , GNUNET_OS_INHERIT_STD_ERR = 4 , GNUNET_OS_INHERIT_STD_OUT_AND_ERR = 6 , GNUNET_OS_INHERIT_STD_ALL = 7 , GNUNET_OS_USE_PIPE_CONTROL = 8 } |
Flags that determine which of the standard streams should be inherited by the child process. More... | |
enum | GNUNET_OS_InstallationPathKind { GNUNET_OS_IPK_PREFIX , GNUNET_OS_IPK_BINDIR , GNUNET_OS_IPK_LIBDIR , GNUNET_OS_IPK_DATADIR , GNUNET_OS_IPK_LOCALEDIR , GNUNET_OS_IPK_SELF_PREFIX , GNUNET_OS_IPK_ICONDIR , GNUNET_OS_IPK_DOCDIR , GNUNET_OS_IPK_LIBEXECDIR } |
Possible installation paths to request. More... | |
enum | GNUNET_OS_ProcessStatusType { GNUNET_OS_PROCESS_UNKNOWN , GNUNET_OS_PROCESS_RUNNING , GNUNET_OS_PROCESS_STOPPED , GNUNET_OS_PROCESS_EXITED , GNUNET_OS_PROCESS_SIGNALED } |
Process status types. More... | |
Functions | |
const struct GNUNET_OS_ProjectData * | GNUNET_OS_project_data_gnunet (void) |
Return default project data used by 'libgnunetutil' for GNUnet. More... | |
void | GNUNET_OS_init (const char *package_name, const struct GNUNET_OS_ProjectData *pd) |
Setup OS subsystem for the given project data and package. More... | |
char * | GNUNET_OS_installation_get_path (const struct GNUNET_OS_ProjectData *pd, enum GNUNET_OS_InstallationPathKind dirkind) |
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX, the current running apps installation directory. More... | |
char * | GNUNET_OS_get_libexec_binary_path (const struct GNUNET_OS_ProjectData *pd, const char *progname) |
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the libexec/-directory to get the full path. More... | |
char * | GNUNET_OS_get_suid_binary_path (const struct GNUNET_OS_ProjectData *pd, const struct GNUNET_CONFIGURATION_Handle *cfg, const char *progname) |
Given the name of a helper, service or daemon binary construct the full path to the binary using the SUID_BINARY_PATH in the PATHS section of the configuration. More... | |
void | GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, void *proc_cls) |
Enumerate all network interfaces. More... | |
struct GNUNET_OS_Process * | GNUNET_OS_process_current (void) |
Get process structure for current process. More... | |
int | GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig) |
Sends a signal to the process. More... | |
void | GNUNET_OS_process_destroy (struct GNUNET_OS_Process *proc) |
Cleans up process structure contents (OS-dependent) and deallocates it. More... | |
pid_t | GNUNET_OS_process_get_pid (struct GNUNET_OS_Process *proc) |
Get the pid of the process in question. More... | |
struct GNUNET_OS_Process * | GNUNET_OS_start_process_vap (enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, struct GNUNET_DISK_PipeHandle *pipe_stderr, const char *filename, char *const argv[]) |
Start a process. More... | |
struct GNUNET_OS_Process * | GNUNET_OS_start_process (enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, struct GNUNET_DISK_PipeHandle *pipe_stderr, const char *filename,...) |
Start a process. More... | |
struct GNUNET_OS_Process * | GNUNET_OS_start_process_va (enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, struct GNUNET_DISK_PipeHandle *pipe_stderr, const char *filename, va_list va) |
Start a process. More... | |
struct GNUNET_OS_Process * | GNUNET_OS_start_process_v (enum GNUNET_OS_InheritStdioFlags std_inheritance, const int *lsocks, const char *filename, char *const argv[]) |
Start a process. More... | |
struct GNUNET_OS_Process * | GNUNET_OS_start_process_s (enum GNUNET_OS_InheritStdioFlags std_inheritance, const int *lsocks, const char *filename,...) |
Start a process. More... | |
void | GNUNET_OS_command_stop (struct GNUNET_OS_CommandHandle *cmd) |
Stop/kill a command. More... | |
struct GNUNET_OS_CommandHandle * | GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, void *proc_cls, struct GNUNET_TIME_Relative timeout, const char *binary,...) |
Run the given command line and call the given function for each line of the output. More... | |
enum GNUNET_GenericReturnValue | GNUNET_OS_process_status (struct GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusType *type, unsigned long *code) |
Retrieve the status of a process. More... | |
enum GNUNET_GenericReturnValue | GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc) |
Wait for a process to terminate. More... | |
enum GNUNET_GenericReturnValue | GNUNET_OS_process_wait_status (struct GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusType *type, unsigned long *code) |
Retrieve the status of a process, waiting on it if dead. More... | |
void | GNUNET_OS_install_parent_control_handler (void *cls) |
Connects this process to its parent via pipe; essentially, the parent control handler will read signal numbers from the GNUNET_OS_CONTROL_PIPE (as given in an environment variable) and raise those signals. More... | |
enum GNUNET_GenericReturnValue | GNUNET_OS_check_helper_binary (const char *binary, bool check_suid, const char *params) |
Check whether an executable exists and possibly if the suid bit is set on the file. More... | |
Low level process routines.
This code manages child processes. We can communicate with child processes using signals. Because signals are not supported on W32 and Java (at least not nicely), we can alternatively use a pipe to send signals to the child processes (if the child process is a full-blown GNUnet process that supports reading signals from a pipe, of course). Naturally, this also only works for 'normal' termination via signals, and not as a replacement for SIGKILL. Thus using pipes to communicate signals should only be enabled if the child is a Java process OR if we are on Windoze.
#define HAVE_SYSCONF 0 |
Definition at line 409 of file gnunet_os_lib.h.
#define GNUNET_OS_get_hostname_max_length | ( | ) | 255 |
Get maximum string length returned by gethostname()
Definition at line 422 of file gnunet_os_lib.h.
typedef enum GNUNET_GenericReturnValue(* GNUNET_OS_NetworkInterfaceProcessor) (void *cls, const char *name, int isDefault, const struct sockaddr *addr, const struct sockaddr *broadcast_addr, const struct sockaddr *netmask, socklen_t addrlen) |
Callback function invoked for each interface found.
cls | closure |
name | name of the interface (can be NULL for unknown) |
isDefault | is this presumably the default interface |
addr | address of this interface (can be NULL for unknown or unassigned) |
broadcast_addr | the broadcast address (can be NULL for unknown or unassigned) |
netmask | the network mask (can be NULL for unknown or unassigned) |
addrlen | length of the address |
Definition at line 371 of file gnunet_os_lib.h.
typedef void(* GNUNET_OS_LineProcessor) (void *cls, const char *line) |
Type of a function to process a line of output.
cls | closure |
line | line of output from a command, NULL for the end |
Definition at line 589 of file gnunet_os_lib.h.
Flags that determine which of the standard streams should be inherited by the child process.
Definition at line 72 of file gnunet_os_lib.h.
Possible installation paths to request.
Definition at line 125 of file gnunet_os_lib.h.
Process status types.
Definition at line 180 of file gnunet_os_lib.h.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet | ( | void | ) |
Return default project data used by 'libgnunetutil' for GNUnet.
Definition at line 82 of file os_installation.c.
References default_pd.
Referenced by auto_config_cb(), client_connect_cb(), communicator_start(), create_unique_cfgs(), enable(), GN_request_connection_reversal(), GNUNET_CADET_open_port(), GNUNET_FS_directory_scan_start(), GNUNET_TESTING_get_topo_from_string_(), GNUNET_TRANSPORT_TESTING_transport_communicator_service_start(), handle_auto_result(), handle_autoconfig_request(), handle_helper_init(), init(), iter_check_config(), load_member(), load_member_session(), load_member_session_next(), load_operation(), load_plugin(), main(), nat_start(), netjail_start_run(), peerstore_start(), resolver_start(), restart_nat_server(), return_agpl(), run(), save_member(), save_member_session(), save_operation(), set_cont(), start_arm_service(), start_helper(), start_peer_run(), start_process(), statistics_start(), and transport_communicator_start().
void GNUNET_OS_init | ( | const char * | package_name, |
const struct GNUNET_OS_ProjectData * | pd | ||
) |
Setup OS subsystem for the given project data and package.
Initializes GNU Gettext.
package_name | name of the package for GNU gettext |
pd | project data to use to determine paths |
Definition at line 89 of file os_installation.c.
References bindtextdomain, GNUNET_free, GNUNET_OS_installation_get_path(), and GNUNET_OS_IPK_LOCALEDIR.
char * GNUNET_OS_installation_get_path | ( | const struct GNUNET_OS_ProjectData * | pd, |
enum GNUNET_OS_InstallationPathKind | dirkind | ||
) |
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX, the current running apps installation directory.
pd | project data to use to determine paths |
dirkind | what kind of directory is desired? |
Definition at line 434 of file os_installation.c.
References DIR_SEPARATOR, DIR_SEPARATOR_STR, GNUNET_asprintf(), GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_OS_IPK_BINDIR, GNUNET_OS_IPK_DATADIR, GNUNET_OS_IPK_DOCDIR, GNUNET_OS_IPK_ICONDIR, GNUNET_OS_IPK_LIBDIR, GNUNET_OS_IPK_LIBEXECDIR, GNUNET_OS_IPK_LOCALEDIR, GNUNET_OS_IPK_PREFIX, GNUNET_OS_IPK_SELF_PREFIX, GNUNET_strdup, GNUNET_YES, os_get_exec_path(), os_get_gnunet_path(), and GNUNET_OS_ProjectData::project_dirname.
Referenced by dump_os_ipk(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_load(), GNUNET_OS_get_libexec_binary_path(), GNUNET_OS_init(), GNUNET_PLUGIN_load_all(), GNUNET_PROGRAM_run2(), GNUNET_SERVICE_run_(), main(), netjail_start_run(), open_library(), run(), and start_helper().
char * GNUNET_OS_get_libexec_binary_path | ( | const struct GNUNET_OS_ProjectData * | pd, |
const char * | progname | ||
) |
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the libexec/-directory to get the full path.
pd | project data to use to determine paths |
progname | name of the binary |
Definition at line 681 of file os_installation.c.
References DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_NO, GNUNET_OS_installation_get_path(), GNUNET_OS_IPK_LIBEXECDIR, GNUNET_strdup, GNUNET_STRINGS_path_is_absolute(), and GNUNET_YES.
Referenced by communicator_start(), GNUNET_HELPER_start(), GNUNET_OS_get_suid_binary_path(), nat_start(), peerstore_start(), resolver_start(), start_arm_service(), start_helper(), start_peer_run(), start_process(), statistics_start(), test_icmp_client(), and test_icmp_server().
char * GNUNET_OS_get_suid_binary_path | ( | const struct GNUNET_OS_ProjectData * | pd, |
const struct GNUNET_CONFIGURATION_Handle * | cfg, | ||
const char * | progname | ||
) |
Given the name of a helper, service or daemon binary construct the full path to the binary using the SUID_BINARY_PATH in the PATHS section of the configuration.
If that option is not present, fall back to GNUNET_OS_get_libexec_binary_path. If progname is an absolute path, a copy of this path is returned.
pd | project data to use to determine paths |
cfg | configuration to inspect |
progname | name of the binary |
Definition at line 712 of file os_installation.c.
References cfg, DIR_SEPARATOR, DIR_SEPARATOR_STR, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_free, GNUNET_NO, GNUNET_OS_get_libexec_binary_path(), GNUNET_strdup, GNUNET_STRINGS_path_is_absolute(), and GNUNET_YES.
Referenced by GN_request_connection_reversal(), restart_nat_server(), and run().
void GNUNET_OS_network_interfaces_list | ( | GNUNET_OS_NetworkInterfaceProcessor | proc, |
void * | proc_cls | ||
) |
Enumerate all network interfaces.
proc | the callback function |
proc_cls | closure for proc |
Definition at line 397 of file os_network.c.
References GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_WARNING, GNUNET_OK, LOG, try_ifconfig(), and try_ip().
Referenced by do_broadcast(), get_addresses(), GNUNET_NT_scanner_init(), run_scan(), scan(), and test_local_ip().
struct GNUNET_OS_Process * GNUNET_OS_process_current | ( | void | ) |
Get process structure for current process.
The pointer it returns points to static memory location and must not be deallocated/closed
The pointer it returns points to static memory location and must not be deallocated/closed.
Definition at line 202 of file os_priority.c.
References current_process, and GNUNET_OS_Process::pid.
int GNUNET_OS_process_kill | ( | struct GNUNET_OS_Process * | proc, |
int | sig | ||
) |
Sends a signal to the process.
proc | pointer to process structure |
sig | signal |
Definition at line 210 of file os_priority.c.
References GNUNET_OS_Process::control_pipe, GNUNET_DISK_file_write(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_TERM_SIG, LOG, GNUNET_OS_Process::pid, and ret.
Referenced by do_stop_task(), exec_bash_script_cleanup(), GN_stop_gnunet_nat_server_(), GNUNET_HELPER_kill(), GNUNET_NAT_mini_get_external_ipv4_cancel_(), GNUNET_OS_command_stop(), GNUNET_PQ_exec_sql(), handle_stop(), maint_child_death(), nat_server_read(), netjail_start_cleanup(), shutdown_process(), shutdown_program(), shutdown_task(), signal_run(), and start_peer_cleanup().
void GNUNET_OS_process_destroy | ( | struct GNUNET_OS_Process * | proc | ) |
Cleans up process structure contents (OS-dependent) and deallocates it.
proc | pointer to process structure |
Definition at line 260 of file os_priority.c.
References GNUNET_OS_Process::control_pipe, GNUNET_DISK_file_close(), and GNUNET_free.
Referenced by child_completed_callback(), exec_bash_script_cleanup(), GN_request_connection_reversal(), GN_stop_gnunet_nat_server_(), GNUNET_HELPER_wait(), GNUNET_NAT_mini_get_external_ipv4_cancel_(), GNUNET_OS_command_stop(), GNUNET_PQ_exec_sql(), maint_child_death(), nat_server_read(), netjail_start_cleanup(), run(), shutdown_process(), start_arm_service(), start_peer_cleanup(), and wait_child().
pid_t GNUNET_OS_process_get_pid | ( | struct GNUNET_OS_Process * | proc | ) |
Get the pid of the process in question.
proc | the process to get the pid of |
Definition at line 253 of file os_priority.c.
References GNUNET_OS_Process::pid.
Referenced by maint_child_death().
struct GNUNET_OS_Process * GNUNET_OS_start_process_vap | ( | enum GNUNET_OS_InheritStdioFlags | std_inheritance, |
struct GNUNET_DISK_PipeHandle * | pipe_stdin, | ||
struct GNUNET_DISK_PipeHandle * | pipe_stdout, | ||
struct GNUNET_DISK_PipeHandle * | pipe_stderr, | ||
const char * | filename, | ||
char *const | argv[] | ||
) |
Start a process.
std_inheritance | a set of GNUNET_OS_INHERIT_STD_* flags |
pipe_stdin | pipe to use to send input to child process (or NULL) |
pipe_stdout | pipe to use to get output from child process (or NULL) |
pipe_stderr | pipe to use to get error output from child process (or NULL) |
filename | name of the binary |
argv | NULL-terminated array of arguments to the process |
Definition at line 567 of file os_priority.c.
References filename, and start_process().
Referenced by exec_bash_script_run(), GNUNET_OS_start_process_va(), handle_uri(), netjail_start_run(), start_helper(), and work().
struct GNUNET_OS_Process * GNUNET_OS_start_process | ( | enum GNUNET_OS_InheritStdioFlags | std_inheritance, |
struct GNUNET_DISK_PipeHandle * | pipe_stdin, | ||
struct GNUNET_DISK_PipeHandle * | pipe_stdout, | ||
struct GNUNET_DISK_PipeHandle * | pipe_stderr, | ||
const char * | filename, | ||
... | |||
) |
Start a process.
std_inheritance | a set of GNUNET_OS_INHERIT_STD_* flags |
pipe_stdin | pipe to use to send input to child process (or NULL) |
pipe_stdout | pipe to use to get output from child process (or NULL) |
pipe_stderr | pipe to use to get error output from child process (or NULL) |
filename | name of the binary |
... | NULL-terminated list of arguments to the process |
Definition at line 620 of file os_priority.c.
References filename, GNUNET_OS_start_process_va(), and ret.
Referenced by GN_request_connection_reversal(), GNUNET_NAT_mini_get_external_ipv4_(), GNUNET_PQ_exec_sql(), nat_start(), peerstore_start(), resolver_start(), restart_nat_server(), run(), and statistics_start().
struct GNUNET_OS_Process * GNUNET_OS_start_process_va | ( | enum GNUNET_OS_InheritStdioFlags | std_inheritance, |
struct GNUNET_DISK_PipeHandle * | pipe_stdin, | ||
struct GNUNET_DISK_PipeHandle * | pipe_stdout, | ||
struct GNUNET_DISK_PipeHandle * | pipe_stderr, | ||
const char * | filename, | ||
va_list | va | ||
) |
Start a process.
std_inheritance | a set of GNUNET_OS_INHERIT_STD_* flags |
pipe_stdin | pipe to use to send input to child process (or NULL) |
pipe_stdout | pipe to use to get output from child process (or NULL) |
pipe_stderr | pipe to use to get error output from child process (or NULL) |
filename | name of the binary |
va | NULL-terminated list of arguments to the process |
Definition at line 585 of file os_priority.c.
References filename, GNUNET_free, GNUNET_malloc, GNUNET_OS_start_process_vap(), and ret.
Referenced by GNUNET_OS_command_run(), GNUNET_OS_start_process(), and run_process_and_wait().
struct GNUNET_OS_Process * GNUNET_OS_start_process_v | ( | enum GNUNET_OS_InheritStdioFlags | std_inheritance, |
const int * | lsocks, | ||
const char * | filename, | ||
char *const | argv[] | ||
) |
Start a process.
std_inheritance | a set of GNUNET_OS_INHERIT_STD_* flags |
lsocks | array of listen sockets to dup systemd-style (or NULL); must be NULL on platforms where dup is not supported |
filename | name of the binary |
argv | NULL-terminated list of arguments to the process, including the process name as the first argument |
Definition at line 643 of file os_priority.c.
References filename, and start_process().
Referenced by GNUNET_OS_start_process_s().
struct GNUNET_OS_Process * GNUNET_OS_start_process_s | ( | enum GNUNET_OS_InheritStdioFlags | std_inheritance, |
const int * | lsocks, | ||
const char * | filename, | ||
... | |||
) |
Start a process.
This function is similar to the GNUNET_OS_start_process_* except that the filename and arguments can have whole strings which contain the arguments. These arguments are to be separated by spaces and are parsed in the order they appear. Arguments containing spaces can be used by quoting them with ".
std_inheritance | a set of GNUNET_OS_INHERIT_STD_* flags |
lsocks | array of listen sockets to dup systemd-style (or NULL); must be NULL on platforms where dup is not supported |
filename | name of the binary. It is valid to have the arguments in this string when they are separated by spaces. |
... | more arguments. Should be of type char * . It is valid to have the arguments in these strings when they are separated by spaces. The last argument MUST be NULL. |
Definition at line 659 of file os_priority.c.
References find_typedefs::arg, filename, GNUNET_free, GNUNET_free_nz, GNUNET_malloc, GNUNET_OS_start_process_v(), and GNUNET_strdup.
Referenced by communicator_start(), start_arm_service(), start_peer_run(), and start_process().
void GNUNET_OS_command_stop | ( | struct GNUNET_OS_CommandHandle * | cmd | ) |
Stop/kill a command.
cmd | handle to the process |
Definition at line 941 of file os_priority.c.
References GNUNET_OS_CommandHandle::eip, GNUNET_assert, GNUNET_break, GNUNET_DISK_pipe_close(), GNUNET_free, GNUNET_OK, GNUNET_OS_process_destroy(), GNUNET_OS_process_kill(), GNUNET_OS_process_wait(), GNUNET_SCHEDULER_cancel(), GNUNET_OS_CommandHandle::opipe, GNUNET_OS_CommandHandle::proc, and GNUNET_OS_CommandHandle::rtask.
Referenced by do_refresh(), GNUNET_NAT_mini_map_stop(), process_map_output(), process_refresh_output(), and process_unmap_output().
struct GNUNET_OS_CommandHandle * GNUNET_OS_command_run | ( | GNUNET_OS_LineProcessor | proc, |
void * | proc_cls, | ||
struct GNUNET_TIME_Relative | timeout, | ||
const char * | binary, | ||
... | |||
) |
Run the given command line and call the given function for each line of the output.
proc | function to call for each line of the output |
proc_cls | closure for proc |
timeout | when to time out |
binary | command to run |
... | arguments to command |
Definition at line 1015 of file os_priority.c.
References cmd_read(), GNUNET_OS_CommandHandle::eip, GNUNET_DISK_PF_BLOCKING_RW, GNUNET_DISK_pipe(), GNUNET_DISK_pipe_close(), GNUNET_DISK_pipe_close_end(), GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_PIPE_END_WRITE, GNUNET_DISK_pipe_handle(), GNUNET_new, GNUNET_OS_INHERIT_STD_NONE, GNUNET_OS_start_process_va(), GNUNET_SCHEDULER_add_read_file(), GNUNET_TIME_relative_to_absolute(), GNUNET_OS_CommandHandle::opipe, GNUNET_OS_CommandHandle::proc, GNUNET_OS_CommandHandle::proc_cls, GNUNET_OS_CommandHandle::r, GNUNET_OS_CommandHandle::rtask, timeout, and GNUNET_OS_CommandHandle::timeout.
Referenced by do_refresh(), GNUNET_NAT_mini_map_stop(), and run_upnpc_r().
enum GNUNET_GenericReturnValue GNUNET_OS_process_status | ( | struct GNUNET_OS_Process * | proc, |
enum GNUNET_OS_ProcessStatusType * | type, | ||
unsigned long * | code | ||
) |
Retrieve the status of a process.
Nonblocking version.
proc | pointer to process structure |
type | status type |
code | return code/signal number |
Definition at line 853 of file os_priority.c.
References process_status(), and type.
Referenced by maint_child_death(), and run_process_and_wait().
enum GNUNET_GenericReturnValue GNUNET_OS_process_wait | ( | struct GNUNET_OS_Process * | proc | ) |
Wait for a process to terminate.
The return code is discarded. You must not use GNUNET_OS_process_status() on the same process after calling this function! This function is blocking and should thus only be used if the child process is known to have terminated or to terminate very soon.
proc | pointer to process structure of the process to wait for |
Definition at line 871 of file os_priority.c.
References GNUNET_ERROR_TYPE_WARNING, GNUNET_OK, GNUNET_SYSERR, LOG_STRERROR, GNUNET_OS_Process::pid, pid, and ret.
Referenced by exec_bash_script_cleanup(), GN_request_connection_reversal(), GN_stop_gnunet_nat_server_(), GNUNET_HELPER_wait(), GNUNET_NAT_mini_get_external_ipv4_cancel_(), GNUNET_OS_command_stop(), nat_server_read(), netjail_start_cleanup(), run(), run_process_and_wait(), shutdown_process(), and start_peer_cleanup().
enum GNUNET_GenericReturnValue GNUNET_OS_process_wait_status | ( | struct GNUNET_OS_Process * | proc, |
enum GNUNET_OS_ProcessStatusType * | type, | ||
unsigned long * | code | ||
) |
Retrieve the status of a process, waiting on it if dead.
Blocking version.
proc | pointer to process structure |
type | status type |
code | return code/signal number |
Definition at line 862 of file os_priority.c.
References process_status(), and type.
Referenced by GNUNET_PQ_exec_sql().
void GNUNET_OS_install_parent_control_handler | ( | void * | cls | ) |
Connects this process to its parent via pipe; essentially, the parent control handler will read signal numbers from the GNUNET_OS_CONTROL_PIPE (as given in an environment variable) and raise those signals.
cls | closure (unused) |
Definition at line 133 of file os_priority.c.
References getenv(), GNUNET_break, GNUNET_DISK_get_handle_from_int_fd(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_OS_CONTROL_PIPE, GNUNET_SCHEDULER_add_read_file(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_TIME_UNIT_FOREVER_REL, LOG, LOG_STRERROR_FILE, parent_control_handler(), pch, shutdown_pch(), and spch.
Referenced by install_parent_control_handler().
enum GNUNET_GenericReturnValue GNUNET_OS_check_helper_binary | ( | const char * | binary, |
bool | check_suid, | ||
const char * | params | ||
) |
Check whether an executable exists and possibly if the suid bit is set on the file.
Attempts to find the file using the current PATH environment variable as a search path.
binary | the name of the file to check. W32: must not have an .exe suffix. |
check_suid | input true if the binary should be checked for SUID (*nix) W32: checks if the program has sufficient privileges by executing this binary with the -d flag. -d omits a programs main loop and only executes all privileged operations in an binary. |
params | parameters used for w32 privilege checking (can be NULL for != w32, or when not checking for suid/permissions ) |
Definition at line 758 of file os_installation.c.
References _, get_path_from_PATH(), GNUNET_asprintf(), GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_strdup, GNUNET_STRINGS_path_is_absolute(), GNUNET_SYSERR, GNUNET_YES, LOG, LOG_STRERROR_FILE, and p.
Referenced by GNUNET_NAT_mini_get_external_ipv4_(), GNUNET_NAT_mini_map_start(), handle_autoconfig_request(), netjail_start_run(), restart_nat_server(), run(), start_process(), test_icmp_client(), test_icmp_server(), and test_upnpc().