be sure to kill a program
Hello,
a doubt: in a script I have to kill both openoffice impress and vlc video player. My solution was: /usr/bin/killall --wait soffice /usr/bin/killall --wait vlc However I note that openoffice run in two processes: soffice and soffice.bin. Killing soffice seems to be like kill both. On man page I note that the default signal killall send is SIGTERM, but time ago was explained to me that the signal that kill most certainly is SIGKILL. Can anyone give me a *five minutes process killing lesson :-)* about this to make me more practical with these approaches? |
killall -9 kills most certainly.Example killall -9 firefox.You need to learn about process and a child process.Here's what you can do to find out how many processes are running under the same name
Code:
ps aux | grep soffice |
And some man page pointers: man signal - for difference between ABRT/KILL/TERM/etc; man kill , man killall, man pgrep, man pkill.
|
I try with --signal SIGKILL (-9), and it is strange but even if
soffice was killed, soffice.bin continues, while when I launch SIGTERM, even soffice.bin was killed. However, from this discussion I think that the right way should be: /usr/bin/killall --signal SIGKILL soffice /usr/bin/killall --signal SIGKILL soffice.bin to be sure this program killed. |
If you send TERM, soffice knows it is being killed and kills soffice.bin. SIGKILL acts instantly. The best way is SIGTERM to soffice, 1..5 second pause and your pair of sigkills. So sometimes the application will have chance to clean up temporary files...
|
Why, may I ask, are you terminating OO and VLC with a script?
|
In these days I made a lot of posts about this (I say
this because I do not want to appear too reduntant or egocentric). Was asked to me to develop a small linux box that should run as a kiosk, without keyboard and mouse, and that is connected via wi-fi to an external lan, that should reproduce powerpoint slideshows and video at loop. So I develop a small approach that use a mixture of php/shell scripts that presents a small web administration interface to the client that could upload what he want to reproduce on the kiosk. When the .ppt file change, seems that there is no way to make openoffice re-read the file, so I have to kill it and restart it. The sleep trick is what I have done before knowing of --wait option of killall (always read the man pages, boys, even if you presume you know about your commands :-) ). |
--wait doesn't solve the problem.. In your case you should only use TERM, to let SOffice terminate gracefully. Sleep trick allows you to send another signal, if subtle hints to terminate are ignored.
|
Is not guaranted that term kill it?
I think that was guaranted but only the time was a variable (I know that some application can ignore it, I would like to know if could happen that signal fails). I used to do ps aux | grep -v grep | grep soffice in a until loop to be sure that was killed. So you think I should launch another after a few seconds? |
TERM can be ignored or incorrectly handled by application, so there are no guarantees. But most applications, if they receive TERM why not hung and not having unsaved changes in open files will terminate eventually. The only signals that are guaranteed to work as expected are STOP, CONT and KILL, and only KILL is relevant to your situation. The drawback is that KILL doesn't let an application to cleanup anything (TERM does - so application can catch it and fail to finish cleanup; ABRT usually leads a quicker termination).
|
All times are GMT -5. The time now is 08:29 PM. |