Avoid setting unsuported parameter for subprocess.Popen on Windows

Signed-off-by: aiordache <anca.iordache@docker.com>
This commit is contained in:
aiordache 2020-12-17 12:09:27 +01:00
parent ca3d5feb67
commit a13b72ae01
1 changed files with 6 additions and 1 deletions

View File

@ -42,12 +42,17 @@ class SSHSocket(socket.socket):
port, port,
'docker system dial-stdio' 'docker system dial-stdio'
] ]
preexec_func = None
if not constants.IS_WINDOWS_PLATFORM:
preexec_func = lambda: signal.signal(signal.SIGINT, signal.SIG_IGN)
self.proc = subprocess.Popen( self.proc = subprocess.Popen(
' '.join(args), ' '.join(args),
shell=True, shell=True,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
preexec_fn=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN)) preexec_fn=preexec_func)
def _write(self, data): def _write(self, data):
if not self.proc or self.proc.stdin.closed: if not self.proc or self.proc.stdin.closed: