mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 19:08:55 +00:00
Merge pull request #3602 from cqjjjzr/fix-rclone-sigint
fix: rclone receiving SIGINT prematurely on Windows causing restic hang forever (#3601)
This commit is contained in:
commit
e5985e0d63
11
changelog/unreleased/issue-3601
Normal file
11
changelog/unreleased/issue-3601
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Bugfix: Fix rclone backend prematurely exiting when receiving SIGINT on Windows
|
||||||
|
|
||||||
|
On Windows, Restic now start the rclone process detached from the
|
||||||
|
restic console (similar to starting processes on a new process
|
||||||
|
group on Linux). Therefore, when Ctrl+C is pressed on the console
|
||||||
|
where restic runs, restic could gracefully clean up using clone,
|
||||||
|
and rclone won't exit prematurely leading to restic hanging up with
|
||||||
|
"stdio pipes closed" errors.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/issue/3601
|
||||||
|
https://github.com/restic/restic/pull/3602
|
@ -2,12 +2,16 @@ package backend
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/errors"
|
"github.com/restic/restic/internal/errors"
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
func startForeground(cmd *exec.Cmd) (bg func() error, err error) {
|
func startForeground(cmd *exec.Cmd) (bg func() error, err error) {
|
||||||
// just start the process and hope for the best
|
// just start the process and hope for the best
|
||||||
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
||||||
|
cmd.SysProcAttr.CreationFlags = windows.DETACHED_PROCESS
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
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