-
Notifications
You must be signed in to change notification settings - Fork 3
/
task.h
64 lines (53 loc) · 1.41 KB
/
task.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
57
58
59
60
61
62
63
64
/*
* task.h
* Copyright (C) 2010-2020 Adrian Perez <[email protected]>
*
* Distributed under terms of the MIT license.
*/
#ifndef __task_h__
#define __task_h__
#include "util.h"
#include <sys/types.h>
typedef enum {
A_NONE = 0,
A_START,
A_STOP,
A_SIGNAL,
} action_t;
typedef struct {
pid_t pid;
action_t action;
int argc;
char **argv;
int write_fd;
int read_fd;
int signal;
time_t started;
uidgid_t user;
unsigned redir_errfd;
} task_t;
#define NO_PID (-1)
#define NO_SIGNAL (-1)
#define TASK { NO_PID, \
A_START, \
0, \
NULL, \
-1, \
-1, \
NO_SIGNAL, \
0, \
UIDGID, \
0 }
#define task_action_queue(task, _action) \
((task)->action = (_action))
#define task_signal_queue(task, _signal) \
((task)->signal = (_signal))
task_t* task_new (int argc, const char **argv);
void task_start (task_t *task);
void task_signal_dispatch (task_t *task);
void task_action_dispatch (task_t *task);
void task_signal (task_t *task, int signum);
void task_action (task_t *task, action_t action);
#endif /* !__task_h__ */
/* vim: expandtab tabstop=4 shiftwidth=4
*/