13
13
import socket
14
14
import sublime
15
15
import subprocess
16
+ import sys
16
17
import threading
17
18
import time
18
19
import weakref
@@ -251,7 +252,8 @@ def _stderr_loop(self) -> None:
251
252
def create_transport (config : TransportConfig , cwd : Optional [str ],
252
253
callback_object : TransportCallbacks ) -> Transport [Dict [str , Any ]]:
253
254
stderr = subprocess .PIPE
254
- pass_fds = () # type: Union[Tuple[()], Tuple[int]]
255
+ # https://github.com/python/cpython/blob/17bf6b4671ec02d80ad29b278639d5307baddeb5/Lib/subprocess.py#L706
256
+ close_fds = True if sys .version_info >= (3 , 8 , 0 ) else subprocess ._PLATFORM_DEFAULT_CLOSE_FDS # type: ignore
255
257
if config .tcp_port is not None :
256
258
assert config .tcp_port is not None
257
259
if config .tcp_port < 0 :
@@ -263,7 +265,7 @@ def create_transport(config: TransportConfig, cwd: Optional[str],
263
265
stdout = subprocess .PIPE
264
266
stdin = subprocess .DEVNULL
265
267
stderr = subprocess .STDOUT
266
- pass_fds = ( config . node_ipc . child_connection . fileno (),)
268
+ close_fds = False
267
269
else :
268
270
stdout = subprocess .PIPE
269
271
stdin = subprocess .PIPE
@@ -273,7 +275,7 @@ def create_transport(config: TransportConfig, cwd: Optional[str],
273
275
process = None # type: Optional[subprocess.Popen]
274
276
275
277
def start_subprocess () -> subprocess .Popen :
276
- return _start_subprocess (config .command , stdin , stdout , stderr , startupinfo , config .env , cwd , pass_fds )
278
+ return _start_subprocess (config .command , stdin , stdout , stderr , startupinfo , config .env , cwd , close_fds )
277
279
278
280
if config .listener_socket :
279
281
assert isinstance (config .tcp_port , int ) and config .tcp_port > 0
@@ -356,7 +358,7 @@ def _start_subprocess(
356
358
startupinfo : Any ,
357
359
env : Dict [str , str ],
358
360
cwd : Optional [str ],
359
- pass_fds : Union [ Tuple [()], Tuple [ int ]]
361
+ close_fds : bool
360
362
) -> subprocess .Popen :
361
363
debug ("starting {} in {}" .format (args , cwd if cwd else os .getcwd ()))
362
364
process = subprocess .Popen (
@@ -367,7 +369,7 @@ def _start_subprocess(
367
369
startupinfo = startupinfo ,
368
370
env = env ,
369
371
cwd = cwd ,
370
- pass_fds = pass_fds )
372
+ close_fds = close_fds )
371
373
_subprocesses .add (process )
372
374
return process
373
375
0 commit comments