#599007 apt-get can't be interrupted with Ctrl+C nor Ctrl-\ anymore

Package:
apt
Source:
apt
Description:
commandline package manager
Submitter:
Adam Borowski
Date:
2026-06-10 07:51:03 UTC
Severity:
normal
#599007#5
Date:
2010-10-03 18:41:02 UTC
From:
To:
It appears that since a recent upgrade, you can't interrupt apt runs
anymore.  That is an important way to recoved from errors before much damage
is done, including:
* genuine user errors
* apt bugs: during a mirror update, the hash won't match, this will make apt
  throw away the Packages file, making a lower-priority source be used
  instead, potentially leading to "remove world, upgrade some" if not caught
  (yeah, running dist-upgrade after a failed update may be considered an
  user error)
* dpkg bugs: when running out of disk space, it will blithely continue other
  operations, potentially breaking more and more packages

I can't think of any good reasons apt should ignore such signals for.  And
in any of these situations, a quick abort within a couple of seconds can
save a hours long recovery.  After frantically pounding on Ctrl-C, Ctrl-\
and watching them fail, suspecting a HUP would be ignored as well, locating
a free console, sshing in, su - ing, killall apt-get, it will manage to do
seriously more damage in that time.

#599007#10
Date:
2010-10-06 13:58:41 UTC
From:
To:
Thanks for your bugreport.
[..]

This is a bug in the code, it looks like this is a regression caused
by setting the termios rtt var via "rtt.c_lflag |= ISIG". This fixed
making it possible to background dpkg, but apparently it broke
ctrl-c. Which is odd given that the documentation says that is is used
to enable signals.

Cheers,
 Michael

#599007#15
Date:
2010-10-06 14:32:58 UTC
From:
To:
I remember disabling it in a program of mine:
http://angband.pl/viewvc/kbtin/trunk/user_tty.c?view=markup
and after checking again, it does work as in the documentation.

Quoting glibc's docs:

# -- Macro: tcflag_t ISIG
#     This bit controls whether the INTR, QUIT, and SUSP characters are
#     recognized.  The functions associated with these characters are
#     performed if and only if this bit is set.  Being in canonical or
#     noncanonical input mode has no affect on the interpretation of
#     these characters.
#
#     You should use caution when disabling recognition of these
#     characters.  Programs that cannot be interrupted interactively are
#     very user-unfriendly.  If you clear this bit, your program should
#     provide some alternate interface that allows the user to
#     interactively send the signals associated with these characters,
#     or to escape from the program.

With that bit clear, Ctrl-C produces a character 0x03.  With it set, it
sends SIGINT.

I didn't look at the apt code, but there must be more to it than merely
setting this flag.

#599007#20
Date:
2026-06-10 07:44:49 UTC
From:
To:
Ctrl-C not simply terminating apt any more might be good
from a package installation consistency view.

But that should be reverted for any subshells that get opened!


When there's a merge conflict in some config file,
opening the relevant files in vim shows unexpected behaviour --
eg. canceling a commandline with Ctrl-C doesn't work any more,
and this breaks (at least my) muscle memory.