> How to kill processes under UNIX SVR4 ?
> When a terminal is disconnected from a UNIX system, the attached process
> and all child processes have to be killed.
> This should happen automatically by UNIX but this is not always the case.
> I have therefore written a function which periodically verifies if the
> process is still attached to its parent.
> I have used the function GETPPID who returns the process ID of the parent
> process, wich is 1 if the parent does not exist anymore.
> If the result is yes 1, the program must exit.
> This method is wrong with a SEQUENT and RM400 SIEMENS where we have found
> normal processes with PPID = 1. (It seems that each UNIX session begins
> with PID=1 instead of a circular numbering for all processes.)
> Has someone an idea for a universal method to solve this problem ?
> Thanks for your help and best wishes for a happy new year.
This sounds like a bad idea - there are lots of processes likely to be
detached from their parents (background processes, daemons etc.).
Killing anything with a PPID of 1 is definitely bad; the 'init' process
is always (on all Unix systems I've used anyway) PID 1 and this starts
and maintains most of the system daemons that are ESSENTIAL for
operation.
You MIGHT be safe if you check that the process's UID is not 0 as well
as PPID=1, since really important processes will be run as root. I've
not checked this thoroughly be VERY careful...it may also still miss a
few things, where programs run suid root to do certain things.
Please don't blame me if the whole thing goes up in smoke...it sounds
like there's some fundamental problem if the processes are not being
killed as you expect them to be.
--
Pete Ford Unix Sys. Admin. Oxford University Computing Services
Phone: +44 1865 2~73266 Look mum, a real job!
"I'm sorry but you need more help than I can give you over the phone"-
R. Letts
The above message represents my personal opinion; neither my employers,
nor any other organisation, is responsible for statements made therein