OpenVAS Scanner 23.23.1
processes.c File Reference

Creates new threads. More...

#include "processes.h"
#include "../misc/kb_cache.h"
#include "debug_utils.h"
#include "sighand.h"
#include <errno.h>
#include <glib.h>
#include <gvm/base/logging.h>
#include <gvm/util/mqtt.h>
#include <setjmp.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>

Macros

#define G_LOG_DOMAIN   "sd main"
 GLib log domain.

Functions

int procs_cleanup_children (void)
 iterates through ipcc and verify if a child is stopped or killed to free the file handler.
static void clean_procs (void)
 Cleans the process list and frees memory. This will not terminate child processes. Is primarily used after fork.
int terminate_process (pid_t pid)
 Terminates a given process. If termination does not work, the process will get killed. Terminate process can be called with the (-1 * pid) to send the signal to the process group.
void procs_terminate_childs (void)
 This function terminates all processes spawned with create_process. Calls terminate_child for each process active. In case init_procs was not called this function does nothing.
static void init_child_signal_handlers (void)
static void pre_fn_call (struct ipc_context *ctx, void *args)
static void post_fn_call (struct ipc_context *ctx, void *args)
static void reuse_or_add_context (struct ipc_context *ctx)
pid_t create_ipc_process (ipc_process_func func, void *args)
 initializes a communication channels and calls a function with a new process
const struct ipc_contextsprocs_get_ipc_contexts (void)
 returns ipc_contexts.

Variables

static struct ipc_contextsipcc = NULL

Detailed Description

Creates new threads.

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "sd main"

GLib log domain.

Function Documentation

◆ clean_procs()

void clean_procs ( void )
static

Cleans the process list and frees memory. This will not terminate child processes. Is primarily used after fork.

◆ create_ipc_process()

pid_t create_ipc_process ( ipc_process_func func,
void * args )

initializes a communication channels and calls a function with a new process

Parameters
funcFunction to call
argsarguments
Returns
pid of spawned process on success or one of the following errors: FORKFAILED

◆ init_child_signal_handlers()

void init_child_signal_handlers ( void )
static

◆ post_fn_call()

void post_fn_call ( struct ipc_context * ctx,
void * args )
static

◆ pre_fn_call()

void pre_fn_call ( struct ipc_context * ctx,
void * args )
static

◆ procs_cleanup_children()

int procs_cleanup_children ( void )

iterates through ipcc and verify if a child is stopped or killed to free the file handler.

Returns
the amount of freed file handler or -1 on ipcc not initialized

◆ procs_get_ipc_contexts()

const struct ipc_contexts * procs_get_ipc_contexts ( void )

returns ipc_contexts.

Returns
the globally hold array of all ipc_context; do not manipulate them.

◆ procs_terminate_childs()

void procs_terminate_childs ( void )

This function terminates all processes spawned with create_process. Calls terminate_child for each process active. In case init_procs was not called this function does nothing.

◆ reuse_or_add_context()

void reuse_or_add_context ( struct ipc_context * ctx)
static

◆ terminate_process()

int terminate_process ( pid_t pid)

Terminates a given process. If termination does not work, the process will get killed. Terminate process can be called with the (-1 * pid) to send the signal to the process group.

Parameters
pidid of the child process
Returns
int 0 on success, NOCHILD if child does not exist, NOINIT if not initialized

Variable Documentation

◆ ipcc

struct ipc_contexts* ipcc = NULL
static