-
Notifications
You must be signed in to change notification settings - Fork 9
/
sig.h
56 lines (43 loc) · 1.35 KB
/
sig.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* Copyright © 2020 Arista Networks, Inc. All rights reserved.
*
* Use of this source code is governed by the MIT license that can be found
* in the LICENSE file.
*/
#ifndef SIG_H_
# define SIG_H_
# include <limits.h>
# include <signal.h>
# include <sys/epoll.h>
typedef int epoll_handler_fn(int epollfd, const struct epoll_event *ev, int fd, pid_t pid);
enum io_readiness {
READ_READY = 1,
WRITE_READY = 2,
HANGUP = 4,
};
enum {
PRIORITY_FIRST = INT_MIN,
PRIORITY_DEFAULT = 0,
PRIORITY_LAST = INT_MAX,
};
# define EPOLL_HANDLER_CONTINUE (-1)
struct epoll_handler {
epoll_handler_fn *fn;
int fd;
/* The priority defines the order in which this handler should be run. */
int priority;
/* The peer file descriptor represents the other side of the handler's
file descriptor, e.g. the file descriptor that must be written to
with the data from fd. */
int peer_fd;
/* The ready flag describes whether this handler is read-ready, write-ready,
or both. */
enum io_readiness ready;
/* The outer helper pid. */
pid_t helper_pid;
};
void sig_wait(const sigset_t *set, siginfo_t *info);
void sig_forward(const siginfo_t *info, pid_t pid);
void sig_read(int sigfd, siginfo_t *info);
void sig_setup(int epollfd, const sigset_t *set, pid_t helper_pid, epoll_handler_fn *fn);
void sig_setpdeathsig(int signo, int parent_handle);
#endif /* !SIG_H_ */