From 2dcb52782824856a92beaef071ef2d7805479df3 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Fri, 14 Aug 2015 15:32:07 +0200 Subject: [PATCH] Only use Setsid on Unix. Setsid is not a part of syscall.SysProcAttr on Windows, so we only set that on systems that have it. --- backend/sftp/sftp.go | 4 +++- backend/sftp/sftp_unix.go | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 backend/sftp/sftp_unix.go diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go index 71c874f0b..08641fd5e 100644 --- a/backend/sftp/sftp.go +++ b/backend/sftp/sftp.go @@ -28,6 +28,8 @@ type SFTP struct { cmd *exec.Cmd } +var sysProcAttr syscall.SysProcAttr + func startClient(program string, args ...string) (*SFTP, error) { // Connect to a remote host and request the sftp subsystem via the 'ssh' // command. This assumes that passwordless login is correctly configured. @@ -37,7 +39,7 @@ func startClient(program string, args ...string) (*SFTP, error) { cmd.Stderr = os.Stderr // ignore signals sent to the parent (e.g. SIGINT) - cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true} + cmd.SysProcAttr = &sysProcAttr // get stdin and stdout wr, err := cmd.StdinPipe() diff --git a/backend/sftp/sftp_unix.go b/backend/sftp/sftp_unix.go new file mode 100644 index 000000000..577649426 --- /dev/null +++ b/backend/sftp/sftp_unix.go @@ -0,0 +1,12 @@ +// +build !windows + +package sftp + +import ( + "syscall" +) + +func init() { + // ignore signals sent to the parent (e.g. SIGINT) + sysProcAttr = syscall.SysProcAttr{Setsid: true} +}