1313import socket
1414import sublime
1515import subprocess
16+ import sys
1617import threading
1718import time
1819import weakref
@@ -251,7 +252,8 @@ def _stderr_loop(self) -> None:
251252def create_transport (config : TransportConfig , cwd : Optional [str ],
252253 callback_object : TransportCallbacks ) -> Transport [Dict [str , Any ]]:
253254 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
255257 if config .tcp_port is not None :
256258 assert config .tcp_port is not None
257259 if config .tcp_port < 0 :
@@ -263,7 +265,7 @@ def create_transport(config: TransportConfig, cwd: Optional[str],
263265 stdout = subprocess .PIPE
264266 stdin = subprocess .DEVNULL
265267 stderr = subprocess .STDOUT
266- pass_fds = ( config . node_ipc . child_connection . fileno (),)
268+ close_fds = False
267269 else :
268270 stdout = subprocess .PIPE
269271 stdin = subprocess .PIPE
@@ -273,7 +275,7 @@ def create_transport(config: TransportConfig, cwd: Optional[str],
273275 process = None # type: Optional[subprocess.Popen]
274276
275277 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 )
277279
278280 if config .listener_socket :
279281 assert isinstance (config .tcp_port , int ) and config .tcp_port > 0
@@ -356,7 +358,7 @@ def _start_subprocess(
356358 startupinfo : Any ,
357359 env : Dict [str , str ],
358360 cwd : Optional [str ],
359- pass_fds : Union [ Tuple [()], Tuple [ int ]]
361+ close_fds : bool
360362) -> subprocess .Popen :
361363 debug ("starting {} in {}" .format (args , cwd if cwd else os .getcwd ()))
362364 process = subprocess .Popen (
@@ -367,7 +369,7 @@ def _start_subprocess(
367369 startupinfo = startupinfo ,
368370 env = env ,
369371 cwd = cwd ,
370- pass_fds = pass_fds )
372+ close_fds = close_fds )
371373 _subprocesses .add (process )
372374 return process
373375
0 commit comments