summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xranger/ext/rifle.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py
index 1ad699bc..d5c40a0e 100755
--- a/ranger/ext/rifle.py
+++ b/ranger/ext/rifle.py
@@ -300,6 +300,8 @@ class Rifle(object):
 					prefix = ['sudo', '-E', 'su', '-mc']
 				else:
 					prefix = ['/bin/sh', '-c']
+
+				cmd = prefix + [command]
 				if 't' in flags:
 					if 'TERMCMD' not in os.environ:
 						term = os.environ['TERM']
@@ -309,17 +311,22 @@ class Rifle(object):
 							self.hook_logger("Can not determine terminal command.  "
 								"Please set $TERMCMD manually.")
 						os.environ['TERMCMD'] = term
-					cmd = [os.environ['TERMCMD'], '-e'] + prefix + [command]
-				elif 'f' in flags:
-					exe = 'setsid' if 'setsid' in get_executables() else 'nohup'
-					cmd = [exe] + prefix + [command]
-				else:
-					cmd = prefix + [command]
+					cmd = [os.environ['TERMCMD'], '-e'] + cmd
 				if 'f' in flags or 't' in flags:
 					devnull_r = open(os.devnull, 'r')
 					devnull_w = open(os.devnull, 'w')
-					p = Popen(cmd, env=self.hook_environment(os.environ),
-						stdin=devnull_r, stdout=devnull_w, stderr=devnull_w)
+					try:
+						pid = os.fork()
+					except:
+						# fall back to not detaching if fork() is not supported
+						p = Popen(cmd, env=self.hook_environment(os.environ))
+						p.wait()
+					else:
+						if pid == 0:
+							os.setsid()
+							p = Popen(cmd, env=self.hook_environment(os.environ),
+								stdin=devnull_r, stdout=devnull_w, stderr=devnull_w)
+							os._exit(0)
 				else:
 					p = Popen(cmd, env=self.hook_environment(os.environ))
 					p.wait()
?id=de65f505a80ab2cee79fbcc01d24c9eed01691e1'>^
de65f505 ^
520eee23 ^





12727744 ^
520eee23 ^


12727744 ^
dc0c3cc6 ^
c6a6e3a5 ^

dc0c3cc6 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56