]>
Commit | Line | Data |
---|---|---|
cc73685d CB |
1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
2 | ||
f1a4a029 ÇO |
3 | #ifndef __LXC_MONITOR_H |
4 | #define __LXC_MONITOR_H | |
0ad19a3f | 5 | |
f9870943 | 6 | #include <limits.h> |
d38dd64a | 7 | #include <poll.h> |
80f41298 | 8 | #include <sys/param.h> |
e51d4895 DE |
9 | #include <sys/un.h> |
10 | ||
eae6543d | 11 | typedef enum { |
12 | lxc_msg_state, | |
13 | lxc_msg_priority, | |
1787abca | 14 | lxc_msg_exit_code, |
eae6543d | 15 | } lxc_msg_type_t; |
16 | ||
17 | struct lxc_msg { | |
18 | lxc_msg_type_t type; | |
e51d4895 | 19 | char name[NAME_MAX+1]; |
eae6543d | 20 | int value; |
21 | }; | |
22 | ||
e51d4895 | 23 | extern int lxc_monitor_sock_name(const char *lxcpath, struct sockaddr_un *addr); |
9e60f51d DE |
24 | extern int lxc_monitor_fifo_name(const char *lxcpath, char *fifo_path, |
25 | size_t fifo_path_sz, int do_mkdirp); | |
e51d4895 | 26 | extern void lxc_monitor_send_state(const char *name, lxc_state_t state, |
9123e471 | 27 | const char *lxcpath); |
1787abca JTLB |
28 | extern void lxc_monitor_send_exit_code(const char *name, int exit_code, |
29 | const char *lxcpath); | |
e51d4895 | 30 | extern int lxc_monitord_spawn(const char *lxcpath); |
0ad19a3f | 31 | |
2366b8a7 SH |
32 | /* |
33 | * Open the monitoring mechanism for a specific container | |
34 | * The function will return an fd corresponding to the events | |
35 | * Returns a file descriptor on success, < 0 otherwise | |
36 | */ | |
37 | extern int lxc_monitor_open(const char *lxcpath); | |
38 | ||
39 | /* | |
40 | * Blocking read for the next container state change | |
41 | * @fd : the file descriptor provided by lxc_monitor_open | |
42 | * @msg : the variable which will be filled with the state | |
43 | * Returns 0 if the monitored container has exited, > 0 if | |
44 | * data was read, < 0 otherwise | |
45 | */ | |
46 | extern int lxc_monitor_read(int fd, struct lxc_msg *msg); | |
47 | ||
48 | /* | |
49 | * Blocking read for the next container state change with timeout | |
50 | * @fd : the file descriptor provided by lxc_monitor_open | |
51 | * @msg : the variable which will be filled with the state | |
52 | * @timeout : the timeout in seconds to wait for a state change | |
53 | * Returns 0 if the monitored container has exited, > 0 if | |
54 | * data was read, < 0 otherwise | |
55 | */ | |
56 | extern int lxc_monitor_read_timeout(int fd, struct lxc_msg *msg, int timeout); | |
57 | ||
58 | /* | |
59 | * Blocking read from multiple monitors for the next container state | |
60 | * change with timeout | |
13dff219 | 61 | * @fds : struct pollfd describing the fds to use |
2366b8a7 SH |
62 | * @nfds : the number of entries in fds |
63 | * @msg : the variable which will be filled with the state | |
64 | * @timeout : the timeout in seconds to wait for a state change | |
65 | * Returns 0 if the monitored container has exited, > 0 if | |
66 | * data was read, < 0 otherwise | |
67 | */ | |
68 | extern int lxc_monitor_read_fdset(struct pollfd *fds, nfds_t nfds, struct lxc_msg *msg, | |
69 | int timeout); | |
70 | ||
71 | ||
0ad19a3f | 72 | #endif |