Low level process routines. More...
Data Structures | |
| struct | GNUNET_OS_ProjectData |
| Project-specific data used to help the OS subsystem find installation paths. More... | |
| struct | GNUNET_ProcessOptionValue |
| Possible options we can set for a process. More... | |
Macros | |
| #define | GNUNET_OS_get_hostname_max_length() 255 |
| Get maximum string length returned by gethostname() | |
| #define | GNUNET_PROCESS_OPTIONS_ARRAY_MAX_SIZE 32 |
| Maximum number of process options we can set in one pass. | |
| #define | GNUNET_process_option_end_() |
| Terminate the list of the options. | |
| #define | GNUNET_process_option_set_environment(k, v) |
| Set environment variable in child process. | |
| #define | GNUNET_process_option_inherit_fd(p, c) |
| Have child process inherit a file descriptor. | |
| #define | GNUNET_process_option_inherit_rpipe(rpipe, child_fd) |
| Have child process inherit a pipe for reading. | |
| #define | GNUNET_process_option_inherit_wpipe(wpipe, child_fd) |
| Have child process inherit a pipe for writing. | |
| #define | GNUNET_process_option_inherit_lsock(lsock) |
| Pass listen socket to child systemd-style. | |
| #define | GNUNET_process_set_options(proc, ...) |
| Set the requested options for the process. | |
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. | |
| typedef void(* | GNUNET_OS_LineProcessor) (void *cls, const char *line) |
| Type of a function to process a line of output. | |
Functions | |
| const struct GNUNET_OS_ProjectData * | GNUNET_OS_project_data_gnunet (void) |
| Return default project data used by 'libgnunetutil' for GNUnet. | |
| void | GNUNET_OS_init (const char *package_name, const struct GNUNET_OS_ProjectData *pd) |
| Setup OS subsystem for the given project data and package. | |
| 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. | |
| 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. | |
| 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. | |
| void | GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, void *proc_cls) |
| Enumerate all network interfaces. | |
| void | GNUNET_OS_command_stop (struct GNUNET_OS_CommandHandle *cmd) |
| Stop/kill a command. | |
| 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. | |
| struct GNUNET_Process * | GNUNET_process_create (enum GNUNET_OS_InheritStdioFlags std_inheritance) |
| Create a process handle. | |
| enum GNUNET_GenericReturnValue | GNUNET_process_run_command_ap (struct GNUNET_Process *p, const char *filename, va_list va) |
| Set the command and start a process. | |
| enum GNUNET_GenericReturnValue | GNUNET_process_run_command_argv (struct GNUNET_Process *p, const char *filename, const char **argv) |
| Set the command and start a process. | |
| enum GNUNET_GenericReturnValue | GNUNET_process_run_command_va (struct GNUNET_Process *p, const char *filename,...) |
| Set the command and start a process. | |
| enum GNUNET_GenericReturnValue | GNUNET_process_run_command (struct GNUNET_Process *p, const char *command) |
| Set the command and start a process. | |
| enum GNUNET_GenericReturnValue | GNUNET_process_set_options_ (struct GNUNET_Process *proc, unsigned int num_options, const struct GNUNET_ProcessOptionValue options[]) |
| Set the requested options for the process. | |
| enum GNUNET_GenericReturnValue | GNUNET_process_wait (struct GNUNET_Process *proc, bool blocking, enum GNUNET_OS_ProcessStatusType *type, unsigned long *code) |
| Wait for a process to terminate. | |
| void | GNUNET_process_destroy (struct GNUNET_Process *proc) |
| Cleans up process structure contents (OS-dependent) and deallocates it. | |
| pid_t | GNUNET_process_get_pid (const struct GNUNET_Process *proc) |
| Get the pid of the process in question. | |
| enum GNUNET_GenericReturnValue | GNUNET_process_kill (struct GNUNET_Process *proc, int sig) |
| Sends a signal to the process. | |
| struct GNUNET_Process * | GNUNET_process_current (void) |
| Get process structure for current process. | |
| void | GNUNET_process_install_parent_control_handler (void) |
| 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. | |
| 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. | |
| 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. | |
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 GNUNET_OS_get_hostname_max_length | ( | ) | 255 |
Get maximum string length returned by gethostname()
Definition at line 418 of file gnunet_os_lib.h.
| #define GNUNET_PROCESS_OPTIONS_ARRAY_MAX_SIZE 32 |
Maximum number of process options we can set in one pass.
Definition at line 588 of file gnunet_os_lib.h.
| #define GNUNET_process_option_end_ | ( | ) |
Terminate the list of the options.
Definition at line 659 of file gnunet_os_lib.h.
| #define GNUNET_process_option_set_environment | ( | k, | |
| v | |||
| ) |
Set environment variable in child process.
| k | name of the variable |
| v | value to set, NULL to clear |
Definition at line 672 of file gnunet_os_lib.h.
| #define GNUNET_process_option_inherit_fd | ( | p, | |
| c | |||
| ) |
Have child process inherit a file descriptor.
The ownership over the file descriptor is afterwards with the process handle.
| p | open file descriptor in this process |
| c | target file descriptor in the child process |
Definition at line 689 of file gnunet_os_lib.h.
| #define GNUNET_process_option_inherit_rpipe | ( | rpipe, | |
| child_fd | |||
| ) |
Have child process inherit a pipe for reading.
The read-end is detached from the pipe.
| rpipe | open pipe in this process the child should read from |
| child_fd | target file descriptor in the child process |
Definition at line 705 of file gnunet_os_lib.h.
| #define GNUNET_process_option_inherit_wpipe | ( | wpipe, | |
| child_fd | |||
| ) |
Have child process inherit a pipe for writing.
The write-end is detached from the pipe.
| wpipe | open pipe in this process the child should write to |
| child_fd | target file descriptor in the child process |
Definition at line 724 of file gnunet_os_lib.h.
| #define GNUNET_process_option_inherit_lsock | ( | lsock | ) |
Pass listen socket to child systemd-style.
The ownership over the file descriptor remains with the caller!
| lsock | open listen socket to pass to the child |
Definition at line 743 of file gnunet_os_lib.h.
| #define GNUNET_process_set_options | ( | proc, | |
| ... | |||
| ) |
Set the requested options for the process.
If any option fail other options may be or may be not applied.
It should be used with helpers that creates required options, for example:
GNUNET_process_set_options ( proc, GNUNET_process_option_std_inheritance_(si));
| proc | the process to set the options for |
| ... | the list of the options, each option must be created by helpers GNUNET_process_option_NAME(VALUE) |
Definition at line 789 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 367 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 434 of file gnunet_os_lib.h.
Flags that determine which of the standard streams should be inherited by the child process.
Definition at line 74 of file gnunet_os_lib.h.
Possible installation paths to request.
Definition at line 121 of file gnunet_os_lib.h.
Process status types.
Definition at line 176 of file gnunet_os_lib.h.
| enum GNUNET_ProcessOption |
Possible options we can set for a process.
Definition at line 561 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(), 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(), init(), init(), iter_check_config(), load_member(), load_member_session(), load_member_session_next(), load_operation(), load_plugin(), main(), main(), main(), netjail_start_run(), restart_nat_server(), return_agpl(), run(), run(), run(), run(), run(), run(), run(), run(), run(), run(), save_member(), save_member_session(), save_operation(), service_start(), set_cont(), start_arm_service(), start_helper(), start_peer_run(), start_process(), 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(), 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(), service_start(), start_arm_service(), start_helper(), start_peer_run(), start_process(), 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(), run(), run(), 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().
| void GNUNET_OS_command_stop | ( | struct GNUNET_OS_CommandHandle * | cmd | ) |
Stop/kill a command.
| cmd | handle to the process |
Definition at line 224 of file os_priority.c.
References GNUNET_OS_CommandHandle::eip, GNUNET_assert, GNUNET_break, GNUNET_DISK_pipe_close(), GNUNET_free, GNUNET_OK, GNUNET_process_destroy(), GNUNET_process_kill(), GNUNET_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 306 of file os_priority.c.
References cmd_read(), GNUNET_OS_CommandHandle::eip, GNUNET_assert, 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_OK, GNUNET_OS_INHERIT_STD_NONE, GNUNET_process_create(), GNUNET_process_destroy(), GNUNET_process_option_inherit_wpipe, GNUNET_process_run_command_ap(), GNUNET_process_set_options, GNUNET_SCHEDULER_add_read_file(), GNUNET_TIME_relative_to_absolute(), GNUNET_OS_CommandHandle::off, 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().
| struct GNUNET_Process * GNUNET_process_create | ( | enum GNUNET_OS_InheritStdioFlags | std_inheritance | ) |
Create a process handle.
Does not yet start it!
Definition at line 462 of file os_process.c.
References GNUNET_new, p, GNUNET_Process::pid, and GNUNET_Process::std_inheritance.
Referenced by communicator_start(), exec_bash_script_run(), GN_request_connection_reversal(), GNUNET_NAT_mini_get_external_ipv4_(), GNUNET_OS_command_run(), GNUNET_PQ_exec_sql(), handle_uri(), netjail_start_run(), restart_nat_server(), run(), run(), service_start(), start_arm_service(), start_helper(), start_peer_run(), start_process(), and work().
| enum GNUNET_GenericReturnValue GNUNET_process_run_command_ap | ( | struct GNUNET_Process * | p, |
| const char * | filename, | ||
| va_list | va | ||
| ) |
Set the command and start a process.
Client must pass the filename and arguments. Can only be called once per struct GNUNET_Process. Should be called after setting options (if there are any).
| [in,out] | p | process handle for the process to setup |
| filename | name of the binary. It is valid to have the arguments in this string when they are separated by spaces. | |
| va | process arguments, usually including filename as argv[0] again. Should all be of type const char *. The last argument MUST be NULL. |
Definition at line 866 of file os_process.c.
References GNUNET_Process::argv, filename, GNUNET_Process::filename, GNUNET_assert, GNUNET_new_array, GNUNET_NO, GNUNET_OS_check_helper_binary(), GNUNET_strdup, GNUNET_SYSERR, p, and process_start().
Referenced by GNUNET_OS_command_run(), and GNUNET_process_run_command_va().
| enum GNUNET_GenericReturnValue GNUNET_process_run_command_argv | ( | struct GNUNET_Process * | p, |
| const char * | filename, | ||
| const char ** | argv | ||
| ) |
Set the command and start a process.
Client must pass the filename and arguments. Can only be called once per struct GNUNET_Process. Should be called after setting options (if there are any).
| [in,out] | p | process handle for the process to setup |
| filename | name of the binary. It is valid to have the arguments in this string when they are separated by spaces. | |
| argv | process arguments, array MUST be NULL-terminated |
Definition at line 840 of file os_process.c.
References GNUNET_Process::argv, filename, GNUNET_Process::filename, GNUNET_assert, GNUNET_new_array, GNUNET_NO, GNUNET_OS_check_helper_binary(), GNUNET_strdup, GNUNET_SYSERR, p, and process_start().
Referenced by exec_bash_script_run(), start_helper(), and work().
| enum GNUNET_GenericReturnValue GNUNET_process_run_command_va | ( | struct GNUNET_Process * | p, |
| const char * | filename, | ||
| ... | |||
| ) |
Set the command and start a process.
Client must pass the filename and arguments. Can only be called once per struct GNUNET_Process. Should be called after setting options (if there are any).
| [in,out] | p | process handle for the process to setup |
| filename | name of the binary. It is valid to have the arguments in this string when they are separated by spaces. | |
| ... | the process arguments, usually including filename as argv[0] again. Should all be of type const char *. The last argument MUST be NULL. |
Definition at line 903 of file os_process.c.
References filename, GNUNET_process_run_command_ap(), p, and ret.
Referenced by communicator_start(), GN_request_connection_reversal(), GNUNET_PQ_exec_sql(), netjail_start_run(), restart_nat_server(), run(), run(), service_start(), start_peer_run(), and start_process().
| enum GNUNET_GenericReturnValue GNUNET_process_run_command | ( | struct GNUNET_Process * | p, |
| const char * | command | ||
| ) |
Set the command and start a process.
Client must pass the full command, which must include the filename and arguments. Can only be called once per struct GNUNET_Process. Should be called after setting options (if there are any).
| [in,out] | p | process handle for the process to setup |
| command | the command-line to run; quoting with '"' is supported to not separate arguments on whitespace; similarly, you can use '"' to escape quotes |
Definition at line 921 of file os_process.c.
References GNUNET_Process::argv, GNUNET_Process::filename, GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_new_array, GNUNET_NO, GNUNET_OS_check_helper_binary(), GNUNET_strdup, GNUNET_strndup, GNUNET_SYSERR, p, process_start(), and start.
Referenced by GNUNET_NAT_mini_get_external_ipv4_(), handle_uri(), start_arm_service(), and start_process().
| enum GNUNET_GenericReturnValue GNUNET_process_set_options_ | ( | struct GNUNET_Process * | proc, |
| unsigned int | num_options, | ||
| const struct GNUNET_ProcessOptionValue | options[] | ||
| ) |
Set the requested options for the process.
If any option fail other options may be or may be not applied. Options must be set before calling the "GNUNET_process_run_command()" family of functions.
| [in,out] | proc | the process to set the options for |
| num_options | maximum length of the options array | |
| options | array of options, possibly terminated early |
Definition at line 1023 of file os_process.c.
References GNUNET_ProcessOptionValue::details, GNUNET_Process::envs, GNUNET_Process::envs_size, GNUNET_array_append, GNUNET_break, GNUNET_OK, GNUNET_PROCESS_OPTION_END, GNUNET_PROCESS_OPTION_INHERIT_FD, GNUNET_PROCESS_OPTION_INHERIT_LSOCK, GNUNET_PROCESS_OPTION_SET_ENVIRONMENT, GNUNET_strdup, GNUNET_SYSERR, GNUNET_ProcessOptionValue::inherit_fd, GNUNET_ProcessOptionValue::inherit_lsock, GNUNET_ProcessOptionValue::key, EnviEntry::key, GNUNET_Process::map, GNUNET_Process::map_size, GNUNET_ProcessOptionValue::option, options, GNUNET_ProcessOptionValue::parent_fd, GNUNET_ProcessOptionValue::set_environment, GNUNET_ProcessOptionValue::target_fd, ProcessFileMapEntry::target_fd, GNUNET_ProcessOptionValue::value, and EnviEntry::value.
| enum GNUNET_GenericReturnValue GNUNET_process_wait | ( | struct GNUNET_Process * | proc, |
| bool | blocking, | ||
| enum GNUNET_OS_ProcessStatusType * | type, | ||
| unsigned long * | code | ||
| ) |
Wait for a process to terminate.
Retrieve the status of a process. This function may be called repeatedly, it will always return the last status of the process.
| proc | pointer to process structure | |
| blocking | true to wait for the process to terminate | |
| [out] | type | set to process status type |
| [out] | code | return code/signal number |
Definition at line 1085 of file os_process.c.
References GNUNET_Process::exit_code, GNUNET_Process::exit_type, GNUNET_ERROR_TYPE_ERROR, GNUNET_NO, GNUNET_OK, GNUNET_OS_PROCESS_EXITED, GNUNET_OS_PROCESS_RUNNING, GNUNET_OS_PROCESS_SIGNALED, GNUNET_OS_PROCESS_UNKNOWN, GNUNET_SYSERR, LOG_STRERROR, GNUNET_Process::pid, ret, status, and type.
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(), GNUNET_PQ_exec_sql(), maint_child_death(), maint_child_death(), maint_child_death(), maint_child_death(), nat_server_read(), netjail_start_cleanup(), run(), shutdown_process(), and start_peer_cleanup().
| void GNUNET_process_destroy | ( | struct GNUNET_Process * | proc | ) |
Cleans up process structure contents (OS-dependent) and deallocates it.
Does NOT kill a running process.
| [in] | proc | pointer to process structure |
Definition at line 363 of file os_process.c.
References GNUNET_Process::argv, GNUNET_Process::control_pipe, GNUNET_Process::envs, GNUNET_Process::envs_size, GNUNET_Process::filename, GNUNET_break, GNUNET_DISK_file_close(), GNUNET_free, EnviEntry::key, GNUNET_Process::map, GNUNET_Process::map_size, me, and EnviEntry::value.
Referenced by child_completed_callback(), child_completed_callback(), communicator_start(), exec_bash_script_cleanup(), GN_request_connection_reversal(), GN_stop_gnunet_nat_server_(), GNUNET_HELPER_wait(), GNUNET_NAT_mini_get_external_ipv4_(), GNUNET_NAT_mini_get_external_ipv4_cancel_(), GNUNET_OS_command_run(), GNUNET_OS_command_stop(), GNUNET_PQ_exec_sql(), maint_child_death(), maint_child_death(), maint_child_death(), nat_server_read(), netjail_start_cleanup(), restart_nat_server(), run(), run(), service_start(), shutdown_process(), start_arm_service(), start_peer_cleanup(), start_peer_run(), start_process(), wait_child(), and work().
| pid_t GNUNET_process_get_pid | ( | const struct GNUNET_Process * | proc | ) |
Get the pid of the process in question.
| proc | the process to get the pid of |
Definition at line 356 of file os_process.c.
References GNUNET_Process::pid.
Referenced by maint_child_death().
| enum GNUNET_GenericReturnValue GNUNET_process_kill | ( | struct GNUNET_Process * | proc, |
| int | sig | ||
| ) |
Sends a signal to the process.
| proc | pointer to process structure |
| sig | signal |
Definition at line 307 of file os_process.c.
References GNUNET_Process::control_pipe, GNUNET_Process::filename, GNUNET_DISK_file_write(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log_strerror, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, LOG, GNUNET_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(), handle_stop(), maint_child_death(), nat_server_read(), netjail_start_cleanup(), shutdown_process(), shutdown_program(), shutdown_task(), signal_run(), and start_peer_cleanup().
| struct GNUNET_Process * GNUNET_process_current | ( | void | ) |
Get process structure for current process.
The pointer it returns points to static memory location and must not be deallocated/closed.
Definition at line 299 of file os_process.c.
References current_process, and GNUNET_Process::pid.
| void GNUNET_process_install_parent_control_handler | ( | void | ) |
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.
Definition at line 223 of file os_process.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.
| 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 111 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(), GNUNET_process_run_command(), GNUNET_process_run_command_ap(), GNUNET_process_run_command_argv(), handle_autoconfig_request(), netjail_start_run(), restart_nat_server(), run(), run(), run(), run(), test_icmp_client(), test_icmp_server(), and test_upnpc().