LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-20-2011, 01:59 PM   #1
jeriryan
Member
 
Registered: Apr 2003
Location: United States
Distribution: RHEL 5.4, Snow Leopard
Posts: 87

Rep: Reputation: 15
killall doesn't work depending on how it's called


I've got a daemon that, when started manually from the command line as root, will eventually (after triggered) call killall5 and kill all running processes. But when the daemon is started as an init script in /etc/init.d, the killall5 doesn't actually kill anything when it is eventually triggered. I know the daemon runs, but the killall5 doesn't kill any processes. I know that killall5 excludes processes in it's own session, but as I noob I don't really understand how that helps me.

Looking at ps -ef for my daemon, when started thru the init scripts it looks like this:
root 5408 1 3 18:23 ? daemon_name
and of course PID 1 is init [3].

when started manually, the trace of the process which eventually leads back to init [3] is much longer. Parent PID of the daemon is -bash, parent of that is su -, parent of that is bash, parent of that is, sshd (I'm sshd in), ..., eventually back to init [3].

So what does the "except kernel threads and the processes in its own session" clarifier in killall5 mean and is it preventing me from killing processes when the daemon calls it when the daemon is started in /etc/init.d?
 
Old 07-20-2011, 03:23 PM   #2
MacKtheHacK
Member
 
Registered: Jul 2003
Location: Boston, MA, USA
Distribution: RedHat, SuSE, Gentoo, Slackware, Mandrake ...
Posts: 111

Rep: Reputation: 15
A "session" is the set of processes descended from a login process, or some other process that called setsid(2). Each process is a member of a "process group" (or "session"), which is used to indicate that processes are logically related in some way. A daemon process should call setsid(2) to place itself into a new process group and disassociate itself from any controlling terminal (along with closing its standard I/O streams and such stuff).

Killall5 does not kill processes in its own process group to avoid killing the shell you invoked it from. If it didn't skip over it's process group, you would get logged off whenever you ran it. Or the rc-script that runs it would get killed off and wouldn't be able to continue the shutdown process.

Kernel threads are the process-table entries whose command names are shown in square brackets. You don't want killall5 to stop them or the kernel would stop right away.

I'm not sure why it isn't killing anything when it is run as a daemon, when it is presumably the only process in its process group. It should kill off every other process. So without more data, I'm at a loss here. But hopefully the above info will help you.

Try checking the exit status of killall5 to see if it tried to kill anything or not.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Keyboard doesn't work right click on mouse doesn't work ramblinrick Linux Mint 2 10-15-2010 01:10 AM
/sbin/halt called by ups monitoring software doesnt work? HighLife Linux - Software 2 06-11-2008 08:50 PM
realloc doesn't work unless memset is called sydney-troz Programming 5 02-29-2008 08:28 PM
wget does not work when called by cron kapster Linux - Newbie 2 09-27-2007 03:06 AM
segfault caused depending on how a function is called emge1 Programming 6 04-04-2007 03:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:07 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration