Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have come across A LOT of annoying and stubborn tasks in the last months that really just ignore SIGTERM and then still need to killed and forcefully removed by SIGKILL.
What I usually do is use SIGTERM twice. If it reports that no such task exists after the second time, it has worked properly (funny: showing an error means worked as it should).
Often though, it reports nothing, and is useless. So I still have to use a SIGKILL afterwards to get the job finally done.
Is there a command that does this already? First sends a nice one and checks if the process really got terminated and otherwise sends one that will work in any case?
However... perhaps you are just being a little to hasty. If you want a process to terminate itself graciously (and you probably do), then you should send it a SIGTERM and then wait a reasonable amount of time for it to respond. There is no need to send the same signal twice.
SIGKILL is what a Dungeons & Dragons aficionado at my University referred to as "fodsnipor" = Finger Of Death, No Saving Throw, No Possibility of Resurrection." Or, as "Bones" McCoy would have put it (in the original and as far as I am concerned only Star Trek): "You're dead, Jim." The target is terminated, immediately and unconditionally and with no opportunity to defend itself or to clean up its mess. Probably not what you want to do, and if you find that you must, find out why.
Last edited by sundialsvcs; 04-17-2012 at 08:58 AM.
However... perhaps you are just being a little to hasty. If you want a process to terminate itself graciously (and you probably do), then you should send it a SIGTERM and then wait a reasonable amount of time for it to respond. There is no need to send the same signal twice.
SIGKILL is what a Dungeons & Dragons aficionado at my University referred to as "fodsnipor" = Finger Of Death, No Saving Throw, No Possibility of Resurrection." Or, as "Bones" McCoy would have put it (in the original and as far as I am concerned only Star Trek): "You're dead, Jim." The target is terminated, immediately and unconditionally and with no opportunity to defend itself or to clean up its mess. Probably not what you want to do, and if you find that you must, find out why.
Too bad there is no command, seems funny that I am the first one to come up with this requirement.
The programs and tools I am terminating don't need more than 1 second to clean up, the system is not that heavily loaded that it would take that long to clean up. And when they crash and get stuck, so that only a SIGKILL will help, they won't do any cleanup in any case. I have not so far experienced that a task that I sent a SIGTERM still came around and cleaned up, after I sent a SIGTERM twice, they hang in all cases and just refuse to go away.
I knew that this is possible to do with a script, but it is ugly to have to do this by hand and not use a standardized tool. Especially for such a basic no brain functionality that could be called "kill and make sure that task is really removed"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.