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

kolypto
  • 11,058
  • 12
  • 54
  • 66

2 Answers2

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?

jftuga
  • 5,731
  • 4
  • 42
  • 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.

jaq
  • 109
  • 3