-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
45 lines (39 loc) · 1.07 KB
/
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
36
37
38
39
40
41
42
43
44
45
#include <string.h>
#include <stdlib.h>
#include <sys/prctl.h>
#include "src/cmd/cmd.h"
#include "src/exec/exec.h"
#include "src/gui/gui.h"
int main(int argc, char** argv){
if (argc == 1){
main_loop(0);
}
if (argc > 1){
if (strcmp(argv[1],"--help") == 0 || strcmp(argv[1],"-h") == 0){
print_main_help();
}
if (strcmp(argv[1],"--voice") == 0 || strcmp(argv[1],"-v") == 0){
pid_t pid;
int pipe_fds[2];
pipe(pipe_fds);
pid = fork();
if (pid == 0) {
prctl(PR_SET_PDEATHSIG, SIGKILL);
dup2(pipe_fds[1],STDOUT_FILENO);
close(pipe_fds[0]);
InitGUI(argc,argv);
close(pipe_fds[1]);
}
else if (pid < 0) {
// Error forking
perror("420sh");
}
else {
close(pipe_fds[1]);
main_loop(pipe_fds[0]);
close(pipe_fds[0]);
}
}
}
return EXIT_SUCCESS;
}