aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar KlZX <azszwymmvqdi@yahoo.com>2019-08-19 17:42:42 +0200
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-08-19 22:10:08 +0530
commit80c2c469dac78bac00ca11ee9cf4f05382b170b3 (patch)
tree54e649c02a70390b8455b7332f79fd57ef84959b /src
parentf378743c4962e0c69eadec0ef0d329f9efd63d71 (diff)
downloadnnn-80c2c469dac78bac00ca11ee9cf4f05382b170b3.tar.gz
Fix 100% CPU usage if STDIN closes
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 6e52978..6a4840d 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3447,6 +3447,10 @@ nochange:
goto begin;
}
+ /* If STDIN is no longer a tty (closed) we should exit */
+ if (!isatty(STDIN_FILENO) && !cfg.picker)
+ return;
+
sel = nextsel(presel);
if (presel)
presel = 0;
@@ -4790,7 +4794,7 @@ int main(int argc, char *argv[])
}
/* Confirm we are in a terminal */
- if (!cfg.picker && !(isatty(0) && isatty(1)))
+ if (!cfg.picker && !(isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)))
exit(1);
/* Get the context colors; copier used as tmp var */