aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-04-25 21:11:35 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-04-25 21:11:35 +0530
commit04bd1ea71d6ce1c7ea02bb2f664cb4e73323da2c (patch)
treeadf2d7dff9155f5b2ba1dabee32d243a8c5c765d
parent6186e8b458b489651809b679fcb8d757c8f3aa30 (diff)
downloadnnn-04bd1ea71d6ce1c7ea02bb2f664cb4e73323da2c.tar.gz
Revert "Fix #225"
-rw-r--r--src/nnn.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 5fb992e..d154406 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -936,15 +936,7 @@ static int join(pid_t p, uchar flag)
if (!(flag & F_NOWAIT)) {
/* wait for the child to exit */
do {
- /* Exit if parent has exited */
- if (getppid() == 1) {
- /* Kill child */
- kill(p, SIGKILL);
-
- /* Exit */
- _exit(0);
- }
- } while (waitpid(p, &status, WNOHANG) <= 0);
+ } while (waitpid(p, &status, 0) == -1);
if (WIFEXITED(status)) {
status = WEXITSTATUS(status);
@@ -1008,8 +1000,6 @@ static int spawn(char *file, char *arg1, char *arg2, const char *dir, uchar flag
exitcurses();
pid = xfork(flag);
-
- /* Child */
if (pid == 0) {
if (dir && chdir(dir) == -1)
_exit(1);
@@ -1025,19 +1015,18 @@ static int spawn(char *file, char *arg1, char *arg2, const char *dir, uchar flag
execvp(*argv, argv);
_exit(1);
- }
+ } else {
+ retstatus = join(pid, flag);
- /* Parent */
- retstatus = join(pid, flag);
+ DPRINTF_D(pid);
+ if (flag & F_NORMAL) {
+ nonl();
+ noecho();
+ }
- DPRINTF_D(pid);
- if (flag & F_NORMAL) {
- nonl();
- noecho();
+ free(cmd);
}
- free(cmd);
-
return retstatus;
}