1

Recently, an exception has occurred on the project, which is the following scenario:

When the process runs for a long time, one of the threads is stuck, and the reason is not clear yet.

But one discovery is: when I use kill 15 + pid, the process cannot be killed, but using kill 9 can kill the process.

I've never encountered this before, so wondering if anyone knows?

I tried to find information from internet, but there is no relevant information that can solve this problem. the process is in SL state.

chqrlie
  • 131,814
  • 10
  • 121
  • 189

1 Answers1

2

Because they both send different signals to the process.

From the Linux man page:

The command kill sends the specified signal to the specified processes or process groups.

If no signal is specified, the TERM signal is sent. The default action for this signal is to terminate the process. This signal should be used in preference to the KILL signal (number 9), since a process may install a handler for the TERM signal in order to perform clean-up steps before terminating in an orderly fashion. If a process does not terminate after a TERM signal has been sent, then the KILL signal may be used; be aware that the latter signal cannot be caught, and so does not give the target process the opportunity to perform any clean-up before terminating.

kill -9 generates SIGKILL(9) which, unlike SIGTERM(15), can not be blocked, caught, or ignored by a process.

Why? Because it is designed to be so. It is equivalent to saying:

“Away, you starvelling, you elf-skin, you dried neat’s-tongue, bull’s-pizzle, you stock-fish!”

to a process.

Harith
  • 4,663
  • 1
  • 5
  • 20