Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why "kill -15" fails sometimes?

I have a program developed in C. This program contains 2 sub threads. Some times, When I try to stop my application with kill -15 <pid of main thread> the application does not exit. And I can see only the pid of the main thread in the ps aux output (The pids of the subthreads are not displayed in the outpout of the ps aux). And keep killing the remaining pid with kill -15 <pid> does not cause the termination of this process. Only kill -9 <pid> will cause the termination of the process.

This behaviour happens 3 times in 1000 tries.

  • The OS is OpenWRT Linux
  • The kernel version is 2.6.30
  • Libs: libuClibc-0.9.30.1.so and libpthread-0.9.30.1.so

Please do not consider this topic duplicated with this one, because my program does not contain sigaction handler.

like image 860
MOHAMED Avatar asked Nov 19 '25 21:11

MOHAMED


1 Answers

It's not duplicate, but the answer is the same. Attach strace or gdb and see what it's doing when it's hung. However there are only two explanations: either you (or some library code you're using) blocked SIGTERM with sigprocmask, or the process is stuck in uninterruptable sleep in the kernel, which is usually a result of attempting to access a failing storage device like a dying hard drive or scratched optical disc.

Could you elaborate on what OS, kernel version, libraries, etc. you're using?

like image 181
R.. GitHub STOP HELPING ICE Avatar answered Nov 21 '25 11:11

R.. GitHub STOP HELPING ICE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!