1

Sometimes when an application hangs in bash session (e.g. network lags in telnet, ssh, whatever) I can't kill it with ^C, stop it with ^D and even send it to background with ^Z.

Is there a way to kill it without opening another shell with kill? I guess there's a syscall to interrupt

4

If you are using SSH, try the two ketstroke combination: ~ ^z (tilde, and then control-z). This will escape out of the SSH session. The same can be done with telnet by pressing ^] (ctrl and then ]).

Now you can start a new session and kill the offending process or the entire session. Is this what you are looking for?

  • Yep, looks like a solution, thank you :) I'll test it ASAP. But is there a more universal solution? Maybe, some 'emergency' hotkey can be mapped in bash that kills the current task? – kolypto Jul 27 '10 at 13:17
  • 1
    In you ran inside of screen, you could open a new window and then kill the process. – jftuga Jul 27 '10 at 13:46
  • 1
    @o_O Tync: ^C, ^D and ^Z are the emergency hotkeys. – Dennis Williamson Jul 27 '10 at 14:51
2

You can send the process a SIGQUIT with a Ctrl-\ which sometimes works if the process has a signal handler for SIGTERM (Ctrl-c) or SIGSTOP (Ctrl-z).

If your process is blocking on I/O syscalls (ps shows it in state D,) it's in an uninterruptable sleep and you're going to have to wait until the resource it's waiting for starts responding.

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.