-
Notifications
You must be signed in to change notification settings - Fork 0
/
processing.h
76 lines (71 loc) · 1.86 KB
/
processing.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
65
66
67
68
69
70
71
72
73
74
75
76
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include "shell.tab.h"
#define MAX_JOBS 50
#define DELIMITERS ")(,\n"
char command[256];
typedef struct type_args
{
int type ;
char **args ;
}type_args;
typedef struct process
{
struct process *next_process ;
pid_t pid ;
char **argv ;
char completed ;
char stopped ;
int status ;
char *in, *out, *err ;
} process ;
typedef struct job
{
struct job *next_job ;
char *command ;
process *first_process ;
pid_t pgid ;
char stopped ;
char foreground ;
} job ;
typedef struct variable
{
char *name ;
char *value ;
char exported ;
struct variable *next_variable ;
} variable ;
char *lookup(const char *name);
void set(const char *name, const char *value);
void unset(const char *name);
void setENV(const char *name);
void unsetENV(const char *name);
void update_jobs(void);
void delete_list(process *p);
void free_job(job *j);
void kill_job(const char sig, const int id);
void update_bg_jobs(void);
void print_bg_jobs(void);
void sig_chld(int n, siginfo_t *info , void *foo);
int job_is_stopped(const job *j);
int job_is_completed(const job *j);
process * find_process(const int pid);
void bg(const int n);
void fg(const int n);
void initialize_shell(void);
void load_job(job **j, process *const *p,const char *str, const char foreground);
void launch_process(process *p, pid_t *pid, const char fg);
void launch_job(job *j);
void update_jobs(void);
void put_job_in_foreground(job *j, const char cont);
void put_job_in_background(job *j, const char cont);
void wait_for_job(job *j);
void add_program(process **ptr,char *str,const char *a,const char *b,const char *c) ;
void cleanup(void);
int do_builtin(type_args *command);