2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-26 06:46:34 +00:00

Move backend/sftp.StartForeground to backend/

This commit is contained in:
Alexander Neumann 2018-03-13 21:09:16 +01:00
parent 34f27edc03
commit cf4cf94418
4 changed files with 11 additions and 8 deletions

View File

@ -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{

View File

@ -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 {

View File

@ -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) {

View File

@ -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")
}