mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 21:05:10 +00:00
Create ignoreSigIntProcAttr()
Retrieve the SysProcAttr from a separate function. Completely eliminates syscall from main file.
This commit is contained in:
parent
520b1b65b0
commit
0e7d0d8dba
@ -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()
|
||||
|
@ -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}
|
||||
}
|
||||
|
11
backend/sftp/sftp_windows.go
Normal file
11
backend/sftp/sftp_windows.go
Normal file
@ -0,0 +1,11 @@
|
||||
package sftp
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// ignoreSigIntProcAttr returns a default syscall.SysProcAttr
|
||||
// on Windows.
|
||||
func ignoreSigIntProcAttr() *syscall.SysProcAttr {
|
||||
return &syscall.SysProcAttr{}
|
||||
}
|
Loading…
Reference in New Issue
Block a user