##// END OF EJS Templates
Merge branch 'newkernel' of github.com:ipython/ipython into upstream-newkernel
Brian Granger -
r2946:c7e6d9ea merge
parent child Browse files
Show More
@@ -5,7 +5,7 b' launchers.'
5 # Standard library imports.
5 # Standard library imports.
6 import os
6 import os
7 import socket
7 import socket
8 from subprocess import Popen
8 from subprocess import Popen, PIPE
9 import sys
9 import sys
10
10
11 # System library imports.
11 # System library imports.
@@ -191,20 +191,26 b' def base_launch_kernel(code, xrep_port=0, pub_port=0, req_port=0, hb_port=0,'
191 arguments.extend(extra_arguments)
191 arguments.extend(extra_arguments)
192
192
193 # Spawn a kernel.
193 # Spawn a kernel.
194 if independent:
194 if sys.platform == 'win32':
195 if sys.platform == 'win32':
195 # If using pythonw, stdin, stdout, and stderr are invalid. Popen will
196 proc = Popen(['start', '/b'] + arguments, shell=True)
196 # fail unless they are suitably redirected. We don't read from the
197 # pipes, but they must exist.
198 redirect = PIPE if sys.executable.endswith('pythonw.exe') else None
199 if independent:
200 proc = Popen(['start', '/b'] + arguments, shell=True,
201 stdout=redirect, stderr=redirect, stdin=redirect)
197 else:
202 else:
198 proc = Popen(arguments, preexec_fn=lambda: os.setsid())
199 else:
200 if sys.platform == 'win32':
201 from _subprocess import DuplicateHandle, GetCurrentProcess, \
203 from _subprocess import DuplicateHandle, GetCurrentProcess, \
202 DUPLICATE_SAME_ACCESS
204 DUPLICATE_SAME_ACCESS
203 pid = GetCurrentProcess()
205 pid = GetCurrentProcess()
204 handle = DuplicateHandle(pid, pid, pid, 0,
206 handle = DuplicateHandle(pid, pid, pid, 0,
205 True, # Inheritable by new processes.
207 True, # Inheritable by new processes.
206 DUPLICATE_SAME_ACCESS)
208 DUPLICATE_SAME_ACCESS)
207 proc = Popen(arguments + ['--parent', str(int(handle))])
209 proc = Popen(arguments + ['--parent', str(int(handle))],
210 stdout=redirect, stderr=redirect, stdin=redirect)
211 else:
212 if independent:
213 proc = Popen(arguments, preexec_fn=lambda: os.setsid())
208 else:
214 else:
209 proc = Popen(arguments + ['--parent'])
215 proc = Popen(arguments + ['--parent'])
210
216
General Comments 0
You need to be logged in to leave comments. Login now