Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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?

share|improve this answer
    
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

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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