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