]> git.itanic.dy.fi Git - rrdd/blob - process.h
1b92e5ba621076168b2be20cf413474ce0e40c25
[rrdd] / process.h
1 #ifndef _PROCESS_H
2 #define _PROCESS_H
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <unistd.h>
7 #include <string.h>
8 #include <sys/wait.h>
9 #include <error.h>
10 #include <errno.h>
11 #include <stdint.h>
12 #include <sys/epoll.h>
13
14 struct event_handler;
15
16 typedef int (handle_event_fn_t)(struct event_handler *);
17 typedef int (work_fn_t)(void *);
18
19 struct event_handler {
20         int fd;
21         uint32_t events;
22         handle_event_fn_t *handle_event;
23         char *name;
24 };
25
26 int register_event_handler(struct event_handler *handler, int op);
27
28 int init_jobcontrol(int max_jobs_requested);
29 int poll_job_requests(int timeout);
30 int do_fork(void);
31 int run(const char *p, char *const argv[]);
32 int clear_zombie(int pid);
33 int run_piped(const char *cmd, char *const argv[],
34               int *stdinfd, int *stdoutfd, int *stderrfd);
35 int run_piped_stream(const char *cmd, char *const argv[],
36                      FILE **stdinf, FILE **stdoutf, FILE **stderrf);
37
38 enum {
39         WORK_PRIORITY_HIGH,
40         WORK_PRIORITY_LOW,
41         WORK_PRIORITIES_NUM,
42 };
43
44 int queue_work(unsigned int priority, char *name,
45         int (work_fn)(void *arg), void *arg);
46
47 #endif