mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 21:05:10 +00:00
Move backend/sftp.StartForeground to backend/
This commit is contained in:
parent
34f27edc03
commit
cf4cf94418
@ -1,4 +1,4 @@
|
||||
package sftp
|
||||
package backend
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
@ -7,7 +7,10 @@ import (
|
||||
"github.com/restic/restic/internal/errors"
|
||||
)
|
||||
|
||||
func startForeground(cmd *exec.Cmd) (bg func() error, err error) {
|
||||
// StartForeground runs cmd in the foreground, by temporarily switching to the
|
||||
// new process group created for cmd. The returned function `bg` switches back
|
||||
// to the previous process group.
|
||||
func StartForeground(cmd *exec.Cmd) (bg func() error, err error) {
|
||||
// run the command in it's own process group so that SIGINT
|
||||
// is not sent to it.
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
@ -1,7 +1,7 @@
|
||||
// +build !solaris
|
||||
// +build !windows
|
||||
|
||||
package sftp
|
||||
package backend
|
||||
|
||||
import (
|
||||
"os"
|
||||
@ -24,10 +24,10 @@ func tcsetpgrp(fd int, pid int) error {
|
||||
return errno
|
||||
}
|
||||
|
||||
// startForeground runs cmd in the foreground, by temporarily switching to the
|
||||
// StartForeground runs cmd in the foreground, by temporarily switching to the
|
||||
// new process group created for cmd. The returned function `bg` switches back
|
||||
// to the previous process group.
|
||||
func startForeground(cmd *exec.Cmd) (bg func() error, err error) {
|
||||
func StartForeground(cmd *exec.Cmd) (bg func() error, err error) {
|
||||
// open the TTY, we need the file descriptor
|
||||
tty, err := os.OpenFile("/dev/tty", os.O_RDWR, 0)
|
||||
if err != nil {
|
@ -1,4 +1,4 @@
|
||||
package sftp
|
||||
package backend
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
@ -6,7 +6,7 @@ import (
|
||||
"github.com/restic/restic/internal/errors"
|
||||
)
|
||||
|
||||
// startForeground runs cmd in the foreground, by temporarily switching to the
|
||||
// StartForeground runs cmd in the foreground, by temporarily switching to the
|
||||
// new process group created for cmd. The returned function `bg` switches back
|
||||
// to the previous process group.
|
||||
func startForeground(cmd *exec.Cmd) (bg func() error, err error) {
|
@ -65,7 +65,7 @@ func startClient(program string, args ...string) (*SFTP, error) {
|
||||
return nil, errors.Wrap(err, "cmd.StdoutPipe")
|
||||
}
|
||||
|
||||
bg, err := startForeground(cmd)
|
||||
bg, err := backend.StartForeground(cmd)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "cmd.Start")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user