1833582 Members
3630 Online
110061 Solutions
New Discussion

Re: After kill -9?

 
brian_31
Super Advisor

After kill -9?

Hi All:

I know kill -9 is bad and should be used as a last resort. But assume you have to do a kill -9 on all processes for a particular user, then how do I make sure that file descriptors are closed and shared memory is detached for those processes w/o rebooting. OR conversely how do I prove that the kill -9 has left some file descriptors open and the shared memory is not detached for those processes? Please voice your valuable thoughts.

Thanks
Brian
7 REPLIES 7
Helen French
Honored Contributor

Re: After kill -9?

Your best tool for this would be 'lsof'. This will list you all information you need. Download it and use it. Another command which will be useful will be 'fuser'

# man fuser
# man lsof
Life is a promise, fulfill it!
harry d brown jr
Honored Contributor

Re: After kill -9?

Brian,

If a process loses its memory or file sdescriptors to the never-never world, then the only way to reclaim them is via reboot.

Using glance, lsof, and ipcs you should be able to "see" everything they have "open". If this situation is hibitual, I'd look into the root cause (what caused the hang).

live free or die
harry
Live Free or Die
brian_31
Super Advisor

Re: After kill -9?

Hi:

Thanks. how can i find out what files are open and what shared memory resources are not released for any particular user?

Thanks
Brian.
Steven Sim Kok Leong
Honored Contributor

Re: After kill -9?

Hi,

For shared memory usage, use ipcs.

Check for used shared memory segments and owners of these segments:

# ipcs -b -m

Check for used semaphores and owners of these semaphores:

# ipcs -b -s

Hope this helps. Regards.

Steven Sim Kok Leong
MANOJ SRIVASTAVA
Honored Contributor

Re: After kill -9?

Hi Brian


The easiest way to do is to do a ps -aef | gerp on the process name , generally speaking the -9 will kill the porcess id or leave some indresct process as zombies , or leave the one started on the ports , the best way to find the remanents of teh process is to check for the ps list with the pid of the process you killed.

You can also try lsof from :
ftp://vic.cc.purdue.edu/pub/tools/unix/lsof/


this will list the opne files , proceeses associated with the PID. You can download the binary version from this site for 11.00 64 bit also.



Manoj Srivastava
brian_31
Super Advisor

Re: After kill -9?

Hi Manoj:

Actually we are killing the process via a logoff script which starts from the soft kill and then goes for the hard one. we also log that so that we know for which user we had to a hard kill. so i need to know based on userwise what user left what files open after this logoff and also what shared memory he has not released.

Thanks
Brian.
Steven Sim Kok Leong
Honored Contributor

Re: After kill -9?

Hi,

To remove shared memory segments or semaphores of a particular user, use ipcrm.

man ipcrm for more information.

Hope this helps. Regards.

Steven Sim Kok Leong