mirror of
https://github.com/jarun/nnn.git
synced 2025-01-25 02:06:50 +00:00
Fix #225
This commit is contained in:
parent
e973330c91
commit
32dde3390a
17
src/nnn.c
17
src/nnn.c
|
@ -936,7 +936,15 @@ static int join(pid_t p, uchar flag)
|
||||||
if (!(flag & F_NOWAIT)) {
|
if (!(flag & F_NOWAIT)) {
|
||||||
/* wait for the child to exit */
|
/* wait for the child to exit */
|
||||||
do {
|
do {
|
||||||
} while (waitpid(p, &status, 0) == -1);
|
/* Exit if parent has exited */
|
||||||
|
if (getppid() == 1) {
|
||||||
|
/* Kill child */
|
||||||
|
kill(p, SIGKILL);
|
||||||
|
|
||||||
|
/* Exit */
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
} while (waitpid(p, &status, WNOHANG) <= 0);
|
||||||
|
|
||||||
if (WIFEXITED(status)) {
|
if (WIFEXITED(status)) {
|
||||||
status = WEXITSTATUS(status);
|
status = WEXITSTATUS(status);
|
||||||
|
@ -1000,6 +1008,8 @@ static int spawn(char *file, char *arg1, char *arg2, const char *dir, uchar flag
|
||||||
exitcurses();
|
exitcurses();
|
||||||
|
|
||||||
pid = xfork(flag);
|
pid = xfork(flag);
|
||||||
|
|
||||||
|
/* Child */
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
if (dir && chdir(dir) == -1)
|
if (dir && chdir(dir) == -1)
|
||||||
_exit(1);
|
_exit(1);
|
||||||
|
@ -1015,7 +1025,9 @@ static int spawn(char *file, char *arg1, char *arg2, const char *dir, uchar flag
|
||||||
|
|
||||||
execvp(*argv, argv);
|
execvp(*argv, argv);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
/* Parent */
|
||||||
retstatus = join(pid, flag);
|
retstatus = join(pid, flag);
|
||||||
|
|
||||||
DPRINTF_D(pid);
|
DPRINTF_D(pid);
|
||||||
|
@ -1025,7 +1037,6 @@ static int spawn(char *file, char *arg1, char *arg2, const char *dir, uchar flag
|
||||||
}
|
}
|
||||||
|
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
|
||||||
|
|
||||||
return retstatus;
|
return retstatus;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue