mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
Fix #81: GUI programs shouldn't exit on closing the parent terminal
Issue reproduction steps: 1. Spawn a GUI program e.g. open a PDF file in zathura or evince. 2. Without quitting `nnn` close the terminal. 3. Notice that the application quits too. Can be a nagging issue if someone is not using a drop-down terminal. Fix: detach a GUI child and start it in a new session. There are 2 aspects to this commit: - It fixes #81: in cases where we do not wait for a spawned child we can assume that the child is a GUI process. We detach and spawn the child in a new session. - It changes the behaviour to @Rahi374's suggestion in PR #40 i.e. invoke the DE opener in F_NOWAIT mode.
This commit is contained in:
parent
9a359b06f0
commit
70c39a063d
10
README.md
10
README.md
|
@ -74,8 +74,6 @@ Have fun with it! PRs are welcome. Check out [#1](https://github.com/jarun/nnn/i
|
||||||
- [boost chdir prompt](#boost-chdir-prompt)
|
- [boost chdir prompt](#boost-chdir-prompt)
|
||||||
- [set idle timeout](#set-idle-timeout)
|
- [set idle timeout](#set-idle-timeout)
|
||||||
- [show hot plugged drives](#show-hot-plugged-drives)
|
- [show hot plugged drives](#show-hot-plugged-drives)
|
||||||
- [Troubleshooting](#troubleshooting)
|
|
||||||
- [nnn blocks on opening files](#nnn-blocks-on-opening-files)
|
|
||||||
- [Why fork?](#why-fork)
|
- [Why fork?](#why-fork)
|
||||||
- [Mentions](#mentions)
|
- [Mentions](#mentions)
|
||||||
- [Developers](#developers)
|
- [Developers](#developers)
|
||||||
|
@ -453,14 +451,6 @@ The terminal screensaver is disabled by default. To set the wait time in seconds
|
||||||
|
|
||||||
Enable volume management in your DE file manager and set removable drives or media to be auto-mounted when inserted. Then visit the usual mount point location (`/mnt` or `/media/user`) in `nnn`.
|
Enable volume management in your DE file manager and set removable drives or media to be auto-mounted when inserted. Then visit the usual mount point location (`/mnt` or `/media/user`) in `nnn`.
|
||||||
|
|
||||||
### Troubleshooting
|
|
||||||
|
|
||||||
#### nnn blocks on opening files
|
|
||||||
|
|
||||||
Ideally nnn should not block. Unfortunately, sometimes even the same desktop opener behaves differently on different Linux desktop environments. If `nnn` does block when a file is open, set the environment variable `NNN_NOWAIT` to any non-zero value. For example,
|
|
||||||
|
|
||||||
export NNN_NOWAIT=1
|
|
||||||
|
|
||||||
### Why fork?
|
### Why fork?
|
||||||
|
|
||||||
I chose to fork because:
|
I chose to fork because:
|
||||||
|
|
5
nnn.1
5
nnn.1
|
@ -253,11 +253,6 @@ screensaver.
|
||||||
export NNN_NO_X=1
|
export NNN_NO_X=1
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
\fBNNN_NOWAIT:\fR necessary only if nnn blocks while a file is open.
|
|
||||||
.Bd -literal
|
|
||||||
export NNN_NOWAIT=1
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
\fBNNN_QUOTE_ON:\fR wrap copied paths within single quotes. Useful for pasting
|
\fBNNN_QUOTE_ON:\fR wrap copied paths within single quotes. Useful for pasting
|
||||||
names in the shell.
|
names in the shell.
|
||||||
.Sh KNOWN ISSUES
|
.Sh KNOWN ISSUES
|
||||||
|
|
14
nnn.c
14
nnn.c
|
@ -248,7 +248,6 @@ static char *player;
|
||||||
static char *copier;
|
static char *copier;
|
||||||
static char *editor;
|
static char *editor;
|
||||||
static char *desktop_manager;
|
static char *desktop_manager;
|
||||||
static char nowait = F_NOTRACE;
|
|
||||||
static blkcnt_t ent_blocks;
|
static blkcnt_t ent_blocks;
|
||||||
static blkcnt_t dir_blocks;
|
static blkcnt_t dir_blocks;
|
||||||
static ulong num_files;
|
static ulong num_files;
|
||||||
|
@ -759,6 +758,12 @@ spawn(const char *file, const char *arg1, const char *arg2, const char *dir, uch
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flag & F_NOWAIT) {
|
||||||
|
signal(SIGHUP, SIG_IGN);
|
||||||
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
setsid();
|
||||||
|
}
|
||||||
|
|
||||||
if (flag & F_SIGINT)
|
if (flag & F_SIGINT)
|
||||||
signal(SIGINT, SIG_DFL);
|
signal(SIGINT, SIG_DFL);
|
||||||
execlp(file, file, arg1, arg2, NULL);
|
execlp(file, file, arg1, arg2, NULL);
|
||||||
|
@ -2520,7 +2525,7 @@ nochange:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invoke desktop opener as last resort */
|
/* Invoke desktop opener as last resort */
|
||||||
spawn(utils[OPENER], newpath, NULL, NULL, nowait);
|
spawn(utils[OPENER], newpath, NULL, NULL, F_NOWAIT | F_NOTRACE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -2878,7 +2883,7 @@ nochange:
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
|
||||||
spawn(desktop_manager, path, NULL, path, F_NOTRACE | F_NOWAIT);
|
spawn(desktop_manager, path, NULL, path, F_NOWAIT | F_NOTRACE);
|
||||||
break;
|
break;
|
||||||
case SEL_FSIZE:
|
case SEL_FSIZE:
|
||||||
cfg.sizeorder ^= 1;
|
cfg.sizeorder ^= 1;
|
||||||
|
@ -3341,9 +3346,6 @@ main(int argc, char *argv[])
|
||||||
/* Get the default copier, if set */
|
/* Get the default copier, if set */
|
||||||
copier = getenv("NNN_COPIER");
|
copier = getenv("NNN_COPIER");
|
||||||
|
|
||||||
/* Get nowait flag */
|
|
||||||
nowait |= getenv("NNN_NOWAIT") ? F_NOWAIT : 0;
|
|
||||||
|
|
||||||
/* Enable quotes if opted */
|
/* Enable quotes if opted */
|
||||||
if (getenv("NNN_QUOTE_ON"))
|
if (getenv("NNN_QUOTE_ON"))
|
||||||
cfg.quote = 1;
|
cfg.quote = 1;
|
||||||
|
|
Loading…
Reference in a new issue