OpenVAS Scanner  5.1.3
processes.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* process_func_t) (void *)
 

Functions

pid_t create_process (process_func_t, void *)
 Create a new process (fork). More...
 
int terminate_process (pid_t)
 

Typedef Documentation

◆ process_func_t

typedef void(* process_func_t) (void *)

Definition at line 31 of file processes.h.

Function Documentation

◆ create_process()

pid_t create_process ( process_func_t  ,
void *   
)

Create a new process (fork).

Definition at line 77 of file processes.c.

Referenced by nasl_plugin_launch().

78 {
79  int pid;
80 
81  pid = fork ();
82 
83  if (pid == 0)
84  {
85  init_child_signal_handlers ();
86  srand48 (getpid () + getppid () + (long) time (NULL));
87  (*function) (argument);
88  exit (0);
89  }
90  if (pid < 0)
91  log_write ("Error : could not fork ! Error : %s", strerror (errno));
92  return pid;
93 }
void log_write(const char *str,...)
Write into the logfile / syslog.
Definition: log.c:140
Here is the caller graph for this function:

◆ terminate_process()

int terminate_process ( pid_t  )

Definition at line 43 of file processes.c.

Referenced by loading_handler_stop().

44 {
45  int ret;
46 
47  if (pid <= 0)
48  return 0;
49 
50  ret = kill (pid, SIGTERM);
51 
52  if (ret == 0)
53  {
54  usleep (1000);
55  if (waitpid (pid, NULL, WNOHANG) >= 0)
56  kill (pid, SIGKILL);
57  }
58  return -1;
59 }
Here is the caller graph for this function: