-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
35 lines (33 loc) · 858 Bytes
/
main.c
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
#include"headers.h"
#include"global.h"
#include"initialPrompt.h"
#include"input.h"
char *input;
int main(){
if(getcwd(originalPath, sizeof(originalPath)) == NULL){
perror("Error in getting shell path: ");
exit(1);
}
shellPID = (int)getpid();
int flag = 0;
currentForegroundProcess = shellPID;
signal(SIGINT, sigIntHandler);
signal(SIGTSTP, sigStpHandler);
while(1 && !flag){
initialisePrompt();
input = (char *)malloc(VARIABLE_LENGTH * sizeof(char));
printf("%s ", prompt);
fgets(input, VARIABLE_LENGTH, stdin);
if(input == NULL){
flag = 1;
break;
}
if(strlen(input) > 0 && (strcmp(input, "\n")!=0)){
seprateMultipleCommand(input, &flag);
}
else{
continue;
}
}
return 0;
}