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

Starts the handling of the child processes.

Parameters
procThe child process to be monitored.
cpThe callback to be called, when the child process completed.
cb_clsThe closure for the callback.
Returns
An handle for the the child being monitored.

Definition at line 205 of file child_management.c.

208 {
209  struct GNUNET_ChildWaitHandle *cwh;
210 
212  cwh = GNUNET_new (struct GNUNET_ChildWaitHandle);
213  cwh->proc = proc;
214  cwh->cb = cb;
215  cwh->cb_cls = cb_cls;
217  cwh_tail,
218  cwh);
219  if (NULL == sig_task)
220  {
226  NULL);
227  }
228  return cwh;
229 }
static void child_management_start(void)
Initializing the signal pipe for child handling.
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.
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.
#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.

References GNUNET_ChildWaitHandle::cb, GNUNET_ChildWaitHandle::cb_cls, child_management_start(), cwh_head, cwh_tail, 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(), GNUNET_ChildWaitHandle::proc, sig_task, and sigpipe.

Referenced by handle_uri(), 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.

Stop waiting on this child.

Parameters
cwhThe handle to be removed.

Definition at line 238 of file child_management.c.

239 {
241  cwh_tail,
242  cwh);
243  GNUNET_free (cwh);
244  if (NULL != cwh_head)
245  return;
247 }
static void child_management_done(void)
Clean up.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_free(ptr)
Wrapper around free.

References child_management_done(), cwh_head, cwh_tail, GNUNET_CONTAINER_DLL_remove, and GNUNET_free.

Referenced by netjail_start_cleanup(), netjail_stop_cleanup(), and shutdown_program().

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