From 401ef92c5fae0a2f72d548b7be64ebe84e9a3332 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 6 Dec 2020 18:28:19 +0100 Subject: [PATCH] backup: Fix shutdown hang when running in the background On shutdown the backup commands waits for the terminal output goroutine to stop. However while running in the background the goroutine ignored the canceled context. --- changelog/unreleased/pull-3152 | 8 ++++++++ internal/ui/termstatus/status.go | 6 ++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 changelog/unreleased/pull-3152 diff --git a/changelog/unreleased/pull-3152 b/changelog/unreleased/pull-3152 new file mode 100644 index 000000000..47dd04bd0 --- /dev/null +++ b/changelog/unreleased/pull-3152 @@ -0,0 +1,8 @@ +Bugfix: On Linux `backup` hangs during exit when run as a background job + +On Linux, when running in the background restic failed to stop the terminal +output of the `backup` command after it had completed. This caused restic to +hang until moved to the foreground. This has been fixed. + +https://github.com/restic/restic/pull/3152 +https://forum.restic.net/t/restic-alpine-container-cron-hangs-epoll-pwait/3334 diff --git a/internal/ui/termstatus/status.go b/internal/ui/termstatus/status.go index cfea18386..c0873577c 100644 --- a/internal/ui/termstatus/status.go +++ b/internal/ui/termstatus/status.go @@ -96,11 +96,9 @@ func (t *Terminal) run(ctx context.Context) { for { select { case <-ctx.Done(): - if IsProcessBackground(t.fd) { - // ignore all messages, do nothing, we are in the background process group - continue + if !IsProcessBackground(t.fd) { + t.undoStatus(len(status)) } - t.undoStatus(len(status)) return