libcortex
Event loop library following a "batteries included" approach
Loading...
Searching...
No Matches
fork.h
1#ifndef CRTX_FORK_H
2#define CRTX_FORK_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8/*
9 * Mario Kicherer (dev@kicherer.org) 2019
10 *
11 */
12
13#include "core.h"
14#include "signals.h"
15
16#define CRTX_EVENT_TYPE_FAMILY_FORK (600)
17#define CRTX_FORK_ET_FORK_DONE_PARENT (CRTX_EVENT_TYPE_FAMILY_FORK + 1)
18#define CRTX_FORK_ET_CHILD_STOPPED (CRTX_EVENT_TYPE_FAMILY_FORK + 2)
19#define CRTX_FORK_ET_CHILD_KILLED (CRTX_EVENT_TYPE_FAMILY_FORK + 3)
20
21#define CRTX_FORK_CHILD_STOPPED (1<<0)
22
24 struct crtx_listener_base base;
25
26// struct crtx_signals_listener signal_lstnr;
27// sigchld_cb sigchld_cb;
28
29 pid_t pid;
30 int flags;
31
32 char *user;
33 char *group;
34
35 void (*reinit_cb)(void *cb_data);
36 void *reinit_cb_data;
37
38 void (*pre_fork_callback)(void *cb_data);
39 void *pre_fork_cb_data;
40
41 void (*post_fork_child_callback)(void *cb_data);
42 void *post_fork_child_cb_data;
43 void (*post_fork_parent_callback)(void *cb_data);
44 void *post_fork_parent_cb_data;
45
46 void *sigchld_data;
47
48 // TODO testing! If we do this, we might need to prevent shutdown of certain
49 // listeners in the child to avoid changing the state of the parent process
50 // as well.
51 char reinit_immediately;
52};
53
54struct crtx_listener_base *crtx_setup_fork_listener(void *options);
55CRTX_DECLARE_ALLOC_FUNCTION(fork)
56
57void crtx_fork_init();
58void crtx_fork_finish();
59
60#ifdef __cplusplus
61}
62#endif
63
64#endif
The core definitions of libcortex.
Definition fork.h:23
base structure of a listener
Definition core.h:186