about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorGustav Larsson <gustav.e.larsson@gmail.com>2018-11-04 00:06:32 +0200
committerGustav Larsson <gustav.e.larsson@gmail.com>2019-08-15 22:20:31 +0300
commit86c16ab4b05ccb99afba247a74ab6875e1407075 (patch)
treea46db21e684f2d38122681fdb3fbf70aae254dbb
parent3e27a680f82f759eebd90a20a4920d4984413d6b (diff)
downloadranger-86c16ab4b05ccb99afba247a74ab6875e1407075.tar.gz
Exit if STDIN is closed #1367
Instead of entering a busy-loop if STDIN is closed, terminate ranger

Fixes #1367
Fixes #87
Fixes #525
Fixed #1534
-rw-r--r--ranger/gui/ui.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index 2874ee97..9900ce52 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -277,6 +277,10 @@ class UI(  # pylint: disable=too-many-instance-attributes,too-many-public-method
                 else:
                     if not self.fm.input_is_blocked():
                         self.handle_key(key)
+            elif key == -1 and not os.isatty(sys.stdin.fileno()):
+                # STDIN has been closed
+                self.fm.exit()
+
 
     def setup(self):
         """Build up the UI by initializing widgets."""