mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 23:06:32 +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"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/juju/errors"
|
"github.com/juju/errors"
|
||||||
"github.com/pkg/sftp"
|
"github.com/pkg/sftp"
|
||||||
@ -28,8 +27,6 @@ type SFTP struct {
|
|||||||
cmd *exec.Cmd
|
cmd *exec.Cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
var sysProcAttr syscall.SysProcAttr
|
|
||||||
|
|
||||||
func startClient(program string, args ...string) (*SFTP, error) {
|
func startClient(program string, args ...string) (*SFTP, error) {
|
||||||
// Connect to a remote host and request the sftp subsystem via the 'ssh'
|
// Connect to a remote host and request the sftp subsystem via the 'ssh'
|
||||||
// command. This assumes that passwordless login is correctly configured.
|
// 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
|
cmd.Stderr = os.Stderr
|
||||||
|
|
||||||
// ignore signals sent to the parent (e.g. SIGINT)
|
// ignore signals sent to the parent (e.g. SIGINT)
|
||||||
cmd.SysProcAttr = &sysProcAttr
|
cmd.SysProcAttr = ignoreSigIntProcAttr()
|
||||||
|
|
||||||
// get stdin and stdout
|
// get stdin and stdout
|
||||||
wr, err := cmd.StdinPipe()
|
wr, err := cmd.StdinPipe()
|
||||||
|
@ -6,7 +6,8 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
// ignoreSigIntProcAttr returns a syscall.SysProcAttr that
|
||||||
// ignore signals sent to the parent (e.g. SIGINT)
|
// disables SIGINT on parent.
|
||||||
sysProcAttr = syscall.SysProcAttr{Setsid: true}
|
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