diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go index 08641fd5e..90cb687a9 100644 --- a/backend/sftp/sftp.go +++ b/backend/sftp/sftp.go @@ -10,7 +10,6 @@ import ( "os/exec" "path/filepath" "sort" - "syscall" "github.com/juju/errors" "github.com/pkg/sftp" @@ -28,8 +27,6 @@ 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. @@ -39,7 +36,7 @@ func startClient(program string, args ...string) (*SFTP, error) { cmd.Stderr = os.Stderr // ignore signals sent to the parent (e.g. SIGINT) - cmd.SysProcAttr = &sysProcAttr + cmd.SysProcAttr = ignoreSigIntProcAttr() // get stdin and stdout wr, err := cmd.StdinPipe() diff --git a/backend/sftp/sftp_unix.go b/backend/sftp/sftp_unix.go index 577649426..f924f0d05 100644 --- a/backend/sftp/sftp_unix.go +++ b/backend/sftp/sftp_unix.go @@ -6,7 +6,8 @@ import ( "syscall" ) -func init() { - // ignore signals sent to the parent (e.g. SIGINT) - sysProcAttr = syscall.SysProcAttr{Setsid: true} +// ignoreSigIntProcAttr returns a syscall.SysProcAttr that +// disables SIGINT on parent. +func ignoreSigIntProcAttr() *syscall.SysProcAttr { + return &syscall.SysProcAttr{Setsid: true} } diff --git a/backend/sftp/sftp_windows.go b/backend/sftp/sftp_windows.go new file mode 100644 index 000000000..62f748c6d --- /dev/null +++ b/backend/sftp/sftp_windows.go @@ -0,0 +1,11 @@ +package sftp + +import ( + "syscall" +) + +// ignoreSigIntProcAttr returns a default syscall.SysProcAttr +// on Windows. +func ignoreSigIntProcAttr() *syscall.SysProcAttr { + return &syscall.SysProcAttr{} +}