LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 04-24-2008, 03:05 PM   #1
tanoatlq
Member
 
Registered: Mar 2007
Posts: 157

Rep: Reputation: 30
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?
 
Old 04-24-2008, 03:33 PM   #2
alan_ri
Senior Member
 
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Blog Entries: 5

Rep: Reputation: 127Reputation: 127
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.
 
Old 04-24-2008, 03:41 PM   #3
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
And some man page pointers: man signal - for difference between ABRT/KILL/TERM/etc; man kill , man killall, man pgrep, man pkill.
 
Old 04-25-2008, 01:55 AM   #4
tanoatlq
Member
 
Registered: Mar 2007
Posts: 157

Original Poster
Rep: Reputation: 30
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.
 
Old 04-25-2008, 03:31 AM   #5
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
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...
 
Old 04-25-2008, 10:14 AM   #6
SlowCoder
Senior Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Debian based
Posts: 1,250

Rep: Reputation: 164Reputation: 164
Why, may I ask, are you terminating OO and VLC with a script?
 
Old 04-25-2008, 02:15 PM   #7
tanoatlq
Member
 
Registered: Mar 2007
Posts: 157

Original Poster
Rep: Reputation: 30
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 :-) ).
 
Old 04-25-2008, 02:25 PM   #8
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
--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.
 
Old 04-25-2008, 02:37 PM   #9
tanoatlq
Member
 
Registered: Mar 2007
Posts: 157

Original Poster
Rep: Reputation: 30
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?
 
Old 04-25-2008, 08:54 PM   #10
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
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).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kill a program that is not responding. jmtjet Ubuntu 6 11-22-2006 11:49 PM
how kill a program SciYro Linux - Newbie 5 07-11-2004 04:20 AM
How to kill my program? kewlchen Linux - General 7 08-12-2003 03:40 PM
cannot kill a program Chooco Linux - General 19 07-23-2003 07:01 AM
Kill a program tunedLow Linux - Newbie 3 10-27-2001 02:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration