Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I know I can kill any process with kill -9 command . But sometimes i see that even if I have terminated a program with CTRL+C , the process doesn't get killed . So I want to know the difference between kill -9 vs CTRL+C

share|improve this question
    
See also What causes various signals to be sent? –  Gilles Jan 23 '13 at 22:11
add comment

1 Answer

up vote 5 down vote accepted

^C send the interrupt signal, which can be handled by a program (you can ignore it)

kill -9 send the sigkill signal which kills the program that you can't handle.

That's why you can't kill some programs with ^C

share|improve this answer
3  
One critical difference is that "well behaved" programs will catch ctrl-C and clean up after themselves (detach from any shared resources, destroy temporary files, reset the terminal to a sane state), SIGKILL doesn't give them that chance. BTW, it can happen that a program is stuck in an unkillable state inside the kernel. –  vonbrand Jan 23 '13 at 12:38
3  
@l0b0: ^C sends SIGINT. kill (without -9) sends SIGTERM. Both those work the same, and can be handled by the program, but they're independent signals. –  ams Jan 23 '13 at 13:00
    
If ^C doesn't work then you should try kill next, and then only kill -9 if you have to. The difference is that kill on it's own gives the program chance to clean up its files and whatnot. kill -9 just removes it without asking nicely. –  ams Jan 23 '13 at 13:03
    
Aka. SIGINT (thanks @ams) and SIGKILL –  l0b0 Jan 23 '13 at 13:56
add comment

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.