summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-04-27 00:05:42 +0200
committerhut <hut@lavabit.com>2011-04-27 00:05:42 +0200
commit584fa6be243ff93d4a288b42ab2bfea7640542c0 (patch)
tree7d9f9df77817a01388764f3cd7e54494706cacb4
parent9a99feacea7297f8478e111d8731a4411ad6c1a5 (diff)
downloadranger-584fa6be243ff93d4a288b42ab2bfea7640542c0.tar.gz
core.loader: Fix blocking when using interactive scripts in scope.sh
-rw-r--r--ranger/core/loader.py4
-rwxr-xr-xranger/data/scope.sh4
2 files changed, 5 insertions, 3 deletions
diff --git a/ranger/core/loader.py b/ranger/core/loader.py
index 7fd7dbab..d063148b 100644
--- a/ranger/core/loader.py
+++ b/ranger/core/loader.py
@@ -70,8 +70,9 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware):
 		self.stdout_buffer = ""
 
 	def generate(self):
+		null = open(os.devnull, 'r')
 		self.process = process = Popen(self.args,
-				stdout=PIPE, stderr=PIPE)
+				stdout=PIPE, stderr=PIPE, stdin=null)
 		self.signal_emit('before', process=process, loader=self)
 		if self.silent and not self.read:
 			while process.poll() is None:
@@ -114,6 +115,7 @@ class CommandLoader(Loadable, SignalDispatcher, FileManagerAware):
 				if py3:
 					read = safeDecode(read)
 				self.stdout_buffer += read
+		null.close()
 		self.finished = True
 		self.signal_emit('after', process=process, loader=self)
 
diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh
index 6ab9df51..4d778486 100755
--- a/ranger/data/scope.sh
+++ b/ranger/data/scope.sh
@@ -3,8 +3,8 @@
 # Its output is used as the preview.  ANSI color codes are supported.
 
 # NOTES: This script is considered a configuration file.  If you upgrade
-# ranger, it will be left untouched. (You must update it yourself)
-# NEVER make this script interactive. (by starting mplayer or something)
+# ranger, it will be left untouched. (You must update it yourself.)
+# Also, ranger disables STDIN here, so interactive scripts won't work properly
 
 # Meanings of exit codes:
 # code | meaning    | action of ranger