borg icon indicating copy to clipboard operation
borg copied to clipboard

Ctrl-C does not interrupt borg check

Open ThomasWaldmann opened this issue 2 years ago • 6 comments

Using borg 1.2.6. Running borg check -p.

Apart from printing '^C', Ctrl-C doesn't have an effect.

Pressing Ctrl-C twice didn't abort borg check.

Originally posted by @rvanlaar in https://github.com/borgbackup/borg/issues/6057

ThomasWaldmann avatar Oct 27 '23 20:10 ThomasWaldmann

For create, borg behaves like this:

Pressing Ctrl-C once should make a checkpoint / commit the repo (that can take a while) and then abort.

Pressing Ctrl-C twice aborts immediately.

ThomasWaldmann avatar Oct 27 '23 20:10 ThomasWaldmann

Reproducing:

with remote (ssh://...) repo

  • while doing the repository-part of check: interrupting with Ctrl-C is not possible (1, 2, any amount)
  • while doing the archives-part of check: 2x Ctrl-C aborts the check

with local repo

  • while doing the repository-part of check: 2x Ctrl-C aborts the check
  • while doing the archives-part of check: (not tested, but I assume that 2x Ctrl-C aborts the check)

ThomasWaldmann avatar Oct 27 '23 20:10 ThomasWaldmann

Guess that the repository part of the check running on the remote side might cause this problem.

ThomasWaldmann avatar Oct 27 '23 20:10 ThomasWaldmann

Hmm, this might be difficult to fix in borg 1.x:

  • we ignore sigint for the ssh subprocess (because it must not be killed for clean borg shutdown)
  • it is the ssh subprocess that outputs the remote output of Repository.check()
  • there is no output from the borg client process in this phase

ThomasWaldmann avatar Oct 27 '23 21:10 ThomasWaldmann

Guess this likely has changed due to the sigint ctrl-c related fix a while ago:

  • the fix was not to let Ctrl-C (SIGINT) kill the ssh subprocess, because the ssh connection is needed for clean shutdown of borg.
  • after the fix, because ssh is not killed by Ctrl-C any more, there is no way to interrupt borg if there is no local terminal output of borg.

Likely, this is a borg1 problem only.

In borg2, logging works very differently and in a way that does not have this problem.

ThomasWaldmann avatar Nov 27 '23 17:11 ThomasWaldmann

Workaround: shoot the ssh subprocess of borg in some other way, like e.g.: kill <pid_of_ssh_subprocess>

ThomasWaldmann avatar Nov 27 '23 17:11 ThomasWaldmann