GNUnet  0.11.x
Typedefs | Functions
gnunet_child_management_lib.h File Reference

GNUnet child management api. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* GNUNET_ChildCompletedCallback) (void *cls, enum GNUNET_OS_ProcessStatusType type, long unsigned int exit_code)
 Defines a GNUNET_ChildCompletedCallback which is sent back upon death or completion of a child process. More...
 

Functions

struct GNUNET_ChildWaitHandleGNUNET_wait_child (struct GNUNET_OS_Process *proc, GNUNET_ChildCompletedCallback cb, void *cb_cls)
 Starts the handling of the child processes. More...
 
void GNUNET_wait_child_cancel (struct GNUNET_ChildWaitHandle *cwh)
 Stop waiting on this child. More...
 

Detailed Description

GNUnet child management api.

Author
Christian Grothoff
Dominik Meister
Dennis Neufeld
t3sserakt

Definition in file gnunet_child_management_lib.h.

Typedef Documentation

◆ GNUNET_ChildCompletedCallback

typedef void(* GNUNET_ChildCompletedCallback) (void *cls, enum GNUNET_OS_ProcessStatusType type, long unsigned int exit_code)

Defines a GNUNET_ChildCompletedCallback which is sent back upon death or completion of a child process.

Parameters
clshandle for the callback
typetype of the process
exit_codestatus code of the process

Definition at line 46 of file gnunet_child_management_lib.h.

Function Documentation

◆ GNUNET_wait_child()

struct GNUNET_ChildWaitHandle* GNUNET_wait_child ( struct GNUNET_OS_Process proc,
GNUNET_ChildCompletedCallback  cb,
void *  cb_cls 
)

Starts the handling of the child processes.

Function checks the status of the child process and sends back a GNUNET_ChildCompletedCallback upon completion/death of the child.

Parameters
procchild process which is monitored
cbreference to the callback which is called after completion
cb_clsclosure for the callback
Returns
GNUNET_ChildWaitHandle is returned

Definition at line 195 of file child_management.c.

198 {
199  struct GNUNET_ChildWaitHandle *cwh;
200 
202  "Adding child!\n");
203 
206  cwh->proc = proc;
207  cwh->cb = cb;
208  cwh->cb_cls = cb_cls;
210  cwh_tail,
211  cwh);
212  if (NULL == sig_task)
213  {
219  NULL);
220  }
221  return cwh;
222 }
static void child_management_start()
static struct GNUNET_ChildWaitHandle * cwh_tail
static void maint_child_death(void *cls)
Task triggered whenever we receive a SIGCHLD (child process died) or when user presses CTRL-C.
static struct GNUNET_DISK_PipeHandle * sigpipe
Pipe used to communicate shutdown via signal.
#define LOG(kind,...)
Generic logging shortcut.
static struct GNUNET_ChildWaitHandle * cwh_head
static struct GNUNET_SCHEDULER_Task * sig_task
const struct GNUNET_DISK_FileHandle * GNUNET_DISK_pipe_handle(const struct GNUNET_DISK_PipeHandle *p, enum GNUNET_DISK_PipeEnd n)
Get the handle to a particular pipe end.
Definition: disk.c:1616
@ GNUNET_DISK_PIPE_END_READ
The reading-end of a pipe.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_file(struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
Definition: scheduler.c:1667
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
Struct which defines a Child Wait handle.
GNUNET_ChildCompletedCallback cb
Callback which is called upon completion/death of the child task.
void * cb_cls
Closure for the handle.
struct GNUNET_OS_Process * proc
Child process which is managed.
struct GNUNET_ChildWaitHandle * cwh

References GNUNET_ChildWaitHandle::cb, GNUNET_ChildWaitHandle::cb_cls, child_management_start(), cwh, cwh_head, cwh_tail, GNUNET_CONTAINER_DLL_insert, GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_pipe_handle(), GNUNET_ERROR_TYPE_ERROR, GNUNET_new, GNUNET_SCHEDULER_add_read_file(), GNUNET_TIME_UNIT_FOREVER_REL, LOG, maint_child_death(), GNUNET_ChildWaitHandle::proc, sig_task, and sigpipe.

Referenced by netjail_start_run(), and netjail_stop_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_wait_child_cancel()

void GNUNET_wait_child_cancel ( struct GNUNET_ChildWaitHandle cwh)

Stop waiting on this child.

Definition at line 225 of file child_management.c.

226 {
227  if ((NULL != cwh_head))
228  {
230  cwh_tail,
231  cwh);
232  }
233  if (NULL == cwh_head)
234  {
236  }
237  if (NULL != sig_task)
238  {
240  sig_task = NULL;
241  }
242  GNUNET_free (cwh);
243 }
static void child_management_done()
Clean up.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972

References child_management_done(), cwh, cwh_head, cwh_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), and sig_task.

Referenced by netjail_start_cleanup(), and netjail_stop_cleanup().

Here is the call graph for this function:
Here is the caller graph for this function: