-
Notifications
You must be signed in to change notification settings - Fork 1
/
builtIn.h
39 lines (27 loc) · 972 Bytes
/
builtIn.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
// header guards to prevent double inclusion
#ifndef BUILTIN_H
#define BUILTIN_H
#include <readline/history.h>
#include <termios.h>
#include "parse.h"
#define MAX_COM_SIZE 256
// Source for job control:
// https://www.gnu.org/software/libc/manual/html_node/Implementing-a-Shell.html
/* A job is a pipeline of processes. */
typedef struct job {
struct job *next; /* next active job */
char command[MAX_COM_SIZE]; /* command line, used for messages */
pid_t pid; /* process ID */
// char notified; /* true if user told about stopped job */
} job;
int isBuiltInCommand(char *command);
void executeBuiltInCommand(commandType *command, int type, HISTORY_STATE *historyState, job *head);
void add_job(job **head, pid_t pid, char cmd[]);
void copy_running_jobs(job **head);
void free_jobs(job *head);
void print_running_jobs(job *head);
enum
BUILTIN_COMMANDS {
EXIT, CD, HISTORY, JOBS, KILL, LEN, NO_SUCH_BUILTIN
};
#endif