-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathioHandler.h
More file actions
65 lines (54 loc) · 1.39 KB
/
ioHandler.h
File metadata and controls
65 lines (54 loc) · 1.39 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
63
64
65
#ifndef ioHandler_h
#define ioHandler_h
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <fcntl.h>
typedef enum {
IN,
OUT,
ERR
} io_t;
typedef enum {
ON,
OFF
} on_off_t;
static int stdinBACKUP;
static int stdoutBACKUP;
static int stderrBACKUP;
static int devNULL;
static io_t ioType;
static on_off_t status;
/**
* Initializes the values of the STDIN, STDOUT, and STDERR backups as well as creates the fd for /dev/null.
*/
void init();
/**
* Creates a new process for the io handling of STDIN, STDOUT or STDERR of a child job.
*
* @param pipeIn the pipe from where the ioHandler process should read.
* @param pipeOut the pipe to which the ioHandler should write.
* @param io the type of process, either IN, OUT or ERR.
* @return the pid of the ioHandler process.
*/
pid_t createNewIOHandler(int pipeIn, int pipeOut, io_t io);
/**
* Creates a new process for the io handling of STDIN of a child job to be executed in background.
*
* @param pipeIn the pipe from where the ioHandler process should read.
* @param pipeOut the pipe to which the ioHandler should write.
* @return the pid of the ioHandler process.
*/
pid_t createNewIOHandlerOFF(int pipeIn, int pipeOut);
/**
* Handles SIGUSR1
* @param sig ignored
*/
static void sigusr1Handler(int sig);
/**
* Handles SIGUSR2
* @param sig ignored
*/
static void sigusr2Handler(int sig);
#endif