]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix 100% CPU usage if STDIN closes
authorKlZX <azszwymmvqdi@yahoo.com>
Mon, 19 Aug 2019 15:42:42 +0000 (17:42 +0200)
committerArun Prakash Jana <engineerarun@gmail.com>
Mon, 19 Aug 2019 16:40:08 +0000 (22:10 +0530)
src/nnn.c

index 6e529781a2267f3fcd6618617e0a6bc5639a2c62..6a4840d3e8654629af5758de227845c285b2fa89 100644 (file)
--- 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 */