-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjobs.h
More file actions
62 lines (45 loc) · 1.19 KB
/
jobs.h
File metadata and controls
62 lines (45 loc) · 1.19 KB
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
#ifndef JOBSH
#define JOBSH
#include "util.h"
#include <sys/types.h>
#include <signal.h>
#define PIPE_MAX 256
#define BG 1
#define FG 2
#define ST 4
#define START_JOBID 1
#define TERMFD 255
#define SHELLPRINT_CHKSS 1
#define SHELLPRINT_CHKTERM 1
typedef struct jobs {
pid_t pid[PIPE_MAX];
int jid;
int state;
char cmdline[LINE_MAX];
struct jobs *next;
} jobs;
#define MASK_SIG(how, sig, msk) do { \
sigemptyset(&(msk)); \
sigaddset(&(msk), (sig)); \
if (sigprocmask((how), &(msk), NULL) < 0) \
ERR_EXIT("sigprocmask"); \
} while (0);
#define MASK_ALLSIG(how, msk) do { \
sigfillset(&(msk)); \
if (sigprocmask((how), &(msk), NULL) < 0) \
ERR_EXIT("sigprocmask"); \
} while (0);
#define SIG_TGL(sig, act) do { \
if (sigaction((sig), &(struct sigaction){ \
.sa_handler=(act)}, NULL) < 0) \
ERR_EXIT("sigaction"); \
}while(0);
extern void printjobs();
extern jobs **addjob(pid_t pid, int state, char **cmd);
extern void deljob(pid_t pid);
extern void job_free();
extern void wait_fg(jobs **job);
extern void do_bgfg(char **cmd, int state);
extern void signal_init();
extern void shell_printf(int flags, const char *fmt, ...);
#endif