aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Paul <paul.elder@amanokami.net>2017-09-19 02:30:54 -0400
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-09-19 12:00:54 +0530
commitdf4b557ca15cacc190f1265efe0db7d1cffae085 (patch)
treee55e7c0cfc6cd920a82efd50201bc096318ca73d
parent968beb434af29417a8490ce66435d157cf869495 (diff)
downloadnnn-df4b557ca15cacc190f1265efe0db7d1cffae085.tar.gz
Prevent nnn from waiting on open file process (#40)
* Prevent nnn from waiting on open file process * Add env var flag to not wait for child process when opening file * Set nowait flag once to skip bit-or every time we open a file * Add documentation for NNN_NOWAIT
-rw-r--r--README.md6
-rw-r--r--nnn.16
-rw-r--r--nnn.c6
3 files changed, 17 insertions, 1 deletions
diff --git a/README.md b/README.md
index acc500e..5540e69 100644
--- a/README.md
+++ b/README.md
@@ -353,6 +353,12 @@ Any other value disables colored directories.
The terminal screensaver is disabled by default. To set the wait time in seconds, use environment variable `NNN_IDLE_TIMEOUT`.
+#### open file in new process and make the nnn not block
+
+The desktop file opener should take care of opening files in new processes without causing `nnn` to block.
+If `nnn` does block/freeze when a file is open, then set the environment variable `NNN_NOWAIT` to any
+non-zero value.
+
### Why fork?
I chose to fork because:
diff --git a/nnn.1 b/nnn.1
index 9ad5c82..13d7c35 100644
--- a/nnn.1
+++ b/nnn.1
@@ -207,6 +207,12 @@ screensaver.
echo -n $1 | xsel --clipboard --input
-------------------------------------
.Ed
+.Pp
+\fBNNN_NOWAIT:\fR make nnn not block while a file is open. Only necessary if
+nnn is blocking while a file is open.
+.Bd -literal
+ export NNN_NOWAIT=1
+.Ed
.Sh KNOWN ISSUES
If you are using urxvt you might have to set backspacekey to DEC.
.Sh AUTHORS
diff --git a/nnn.c b/nnn.c
index 3b0ac02..1b1ba40 100644
--- a/nnn.c
+++ b/nnn.c
@@ -222,6 +222,7 @@ static char *player;
static char *copier;
static char *editor;
static char *desktop_manager;
+static char nowait;
static blkcnt_t ent_blocks;
static blkcnt_t dir_blocks;
static ulong num_files;
@@ -2211,7 +2212,7 @@ nochange:
}
/* Invoke desktop opener as last resort */
- spawn(utils[2], newpath, NULL, NULL, F_NOTRACE);
+ spawn(utils[2], newpath, NULL, NULL, nowait);
continue;
}
default:
@@ -2863,6 +2864,9 @@ main(int argc, char *argv[])
/* Get the default copier, if set */
copier = getenv("NNN_COPIER");
+ /* Get nowait flag */
+ nowait = F_NOTRACE | (getenv("NNN_NOWAIT") ? F_NOWAIT : 0);
+
signal(SIGINT, SIG_IGN);
/* Test initial path */