I was connected by ssh to my server, running aptitude upgrade, and, during the process, my Internet connection was off.

After reconnecting, the aptitude upgrade command was still running:

$ ps aux | grep apt
root     15186  0.0  0.0  68996  2108 ?        S    14:09   0:00 sudo aptitude upgrade
root     15187  3.9  1.4 262328 119080 ?       Sl   14:09   0:17 aptitude upgrade

and dpkg process is in locked state. Probably, the command is waiting for a confirmation to install the upgrades (the usual Y/n question).

How can I recover the process control to finish the command cleanly? ("connect" again to the standard input of the process to press 'Y').

If there's no way to do it, how safe is to just make a force kill of the upgrade by PID?

NOTE: I'm aware of reptyr to bring any process to foreground, but since I don't have currently that package, this is not a solution because I cannot use dpkg or its derivates to install new packages because it is in blocked state.


killing it is usually fine, and certainly so if it's just at the Y/n prompt and has not started actually installing packages. At worst you'll need to run apt-get -f install and/or dpkg --configure -a a couple times.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.