From d9c9415cfd96facad6d38aeb835ff2e347234641 Mon Sep 17 00:00:00 2001 From: Charlie Jiang Date: Sun, 3 Apr 2022 17:44:13 +0800 Subject: [PATCH] Fix rclone (scoop shim) and sftp issue due to detached console on Windows --- changelog/unreleased/issue-3692 | 12 ++++++++++++ internal/backend/foreground_windows.go | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/issue-3692 diff --git a/changelog/unreleased/issue-3692 b/changelog/unreleased/issue-3692 new file mode 100644 index 000000000..4b0019888 --- /dev/null +++ b/changelog/unreleased/issue-3692 @@ -0,0 +1,12 @@ +Bugfix: Fix rclone (shimmed by Scoop) and sftp stopped working on Windows + +In #3602 a fix was introduced to fix the problem that rclone prematurely exits +when Ctrl+C is pressed on Windows. The solution was to create the subprocess +with its console detached from the restic console. However, such solution +fails when using rclone install by scoop or using sftp with a passphrase- +protected private key. We've fixed that by using a different approach to prevent +Ctrl-C from passing down too early. + +https://github.com/restic/restic/issues/3681 +https://github.com/restic/restic/issues/3692 +https://github.com/restic/restic/pull/3696 diff --git a/internal/backend/foreground_windows.go b/internal/backend/foreground_windows.go index a299f6211..54883c30f 100644 --- a/internal/backend/foreground_windows.go +++ b/internal/backend/foreground_windows.go @@ -11,7 +11,7 @@ import ( func startForeground(cmd *exec.Cmd) (bg func() error, err error) { // just start the process and hope for the best cmd.SysProcAttr = &syscall.SysProcAttr{} - cmd.SysProcAttr.CreationFlags = windows.DETACHED_PROCESS + cmd.SysProcAttr.CreationFlags = windows.CREATE_NEW_PROCESS_GROUP err = cmd.Start() if err != nil { return nil, errors.Wrap(err, "cmd.Start")