Linux - NewbieThis 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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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 .
when started manually, the trace of the process which eventually leads back to init  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 .
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?
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.