LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   be sure to kill a program (https://www.linuxquestions.org/questions/linux-general-1/be-sure-to-kill-a-program-637611/)

tanoatlq 04-24-2008 03:05 PM

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?

alan_ri 04-24-2008 03:33 PM

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
In this example it was soffice.Then you can decide which one to kill,but as I said you need to learn about processes.Search.

raskin 04-24-2008 03:41 PM

And some man page pointers: man signal - for difference between ABRT/KILL/TERM/etc; man kill , man killall, man pgrep, man pkill.

tanoatlq 04-25-2008 01:55 AM

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.

raskin 04-25-2008 03:31 AM

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...

SlowCoder 04-25-2008 10:14 AM

Why, may I ask, are you terminating OO and VLC with a script?

tanoatlq 04-25-2008 02:15 PM

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 :-) ).

raskin 04-25-2008 02:25 PM

--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.

tanoatlq 04-25-2008 02:37 PM

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?

raskin 04-25-2008 08:54 PM

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.