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 47 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 166 of file child_management.c.

References GNUNET_ChildWaitHandle::cb, GNUNET_ChildWaitHandle::cb_cls, GNUNET_CONTAINER_DLL_insert, GNUNET_DISK_PIPE_END_READ, GNUNET_DISK_pipe_handle(), GNUNET_new, GNUNET_SCHEDULER_add_read_file(), GNUNET_TIME_UNIT_FOREVER_REL, maint_child_death(), and GNUNET_ChildWaitHandle::proc.

169 {
170  struct GNUNET_ChildWaitHandle *cwh;
171 
172  child_management_start ();
173  cwh = GNUNET_new (struct GNUNET_ChildWaitHandle);
174  cwh->proc = proc;
175  cwh->cb = cb;
176  cwh->cb_cls = cb_cls;
178  cwh_tail,
179  cwh);
180  if (NULL == sig_task)
181  {
187  NULL);
188  }
189  return cwh;
190 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static struct GNUNET_DISK_PipeHandle * sigpipe
Pipe used to communicate shutdown via signal.
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_new(type)
Allocate a struct or union of the given type.
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:1436
struct GNUNET_OS_Process * proc
Child process which is managed.
void * cb_cls
Closure for the handle.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
The reading-end of a pipe.
static void maint_child_death(void *cls)
Task triggered whenever we receive a SIGCHLD (child process died) or when user presses CTRL-C...
GNUNET_ChildCompletedCallback cb
Callback which is called upon completion/death of the child task.
static struct GNUNET_ChildWaitHandle * cwh_tail
static struct GNUNET_ChildWaitHandle * cwh_head
static struct GNUNET_SCHEDULER_Task * sig_task
Struct which defines a Child Wait handle.
Here is the call 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 194 of file child_management.c.

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, and GNUNET_SCHEDULER_cancel().

195 {
197  cwh_tail,
198  cwh);
199  if (NULL == cwh_head)
200  {
202  sig_task = NULL;
203  }
204  GNUNET_free (cwh);
205 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct GNUNET_ChildWaitHandle * cwh_tail
static struct GNUNET_ChildWaitHandle * cwh_head
static struct GNUNET_SCHEDULER_Task * sig_task
#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
Here is the call graph for this function: