]> git.itanic.dy.fi Git - rrdd/blob - process.h
onewire_parser: Implement simultaneous reading
[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
13 struct event_handler;
14
15 typedef int (handle_event_fn_t)(struct event_handler *);
16 typedef int (work_fn_t)(void *);
17
18 struct event_handler {
19         int fd;
20         uint32_t events;
21         handle_event_fn_t *handle_event;
22         char *name;
23 };
24
25 int register_event_handler(struct event_handler *handler);
26
27 int init_jobcontrol(int max_jobs_requested);
28 int poll_job_requests(int timeout);
29 int do_fork(void);
30 int run(const char *p, char *const argv[]);
31 int clear_zombie(int pid);
32 int run_piped(const char *cmd, char *const argv[],
33               int *stdinfd, int *stdoutfd, int *stderrfd);
34 int run_piped_stream(const char *cmd, char *const argv[],
35                      FILE **stdinf, FILE **stdoutf, FILE **stderrf);
36
37 enum {
38         WORK_PRIORITY_HIGH,
39         WORK_PRIORITY_LOW,
40         WORK_PRIORITIES_NUM,
41 };
42
43 int queue_work(unsigned int priority, char *name,
44         int (work_fn)(void *arg), void *arg);
45
46 #endif