-
Notifications
You must be signed in to change notification settings - Fork 0
/
openFile.h
35 lines (32 loc) · 696 Bytes
/
openFile.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
#ifndef OPENFILE_H
#define OPENFILE_H
#include "header.h"
void openFile(const char *file){
// if (fork() == 0) {
// // execl("/usr/bin/xdg-open", "xdg-open", file, (char *)0);
// execv(file,"vi");
// exit(1);
// }
// int fileOpen=open("/dev/null",O_WRONLY);
// dup2(fileOpen,2);
// close(fileOpen);
// pid_t processID = fork();
// if(processID == 0)
// {
// // execlp("xdg-open","xdg-open",file,NULL);
// execlp("vi","vi",file,NULL);
// exit(0);
// }
// wait(processID);
pid_t pid = fork();
if (pid == 0) {
// close(2);
execlp("vi", "vi", file, NULL);
exit(0);
}
int status;
waitpid(pid, &status, 0);
while(!WIFEXITED(status))
continue;
}
#endif