Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot grep a living process, it's invisible !

colin the aardvark-OracleNov 8 2011 — edited Nov 9 2011
Hi people, hoping this is an easy answer for the gurus.
In all my years of unix I'd never come across the cntl-Z, bg and fg commands before, so I thought I'd run a tiny script to test them out. Might be useful as the doc says for getting out of a long-running program to do something else... Unfortunately, it turns out that the script I cobbled together has a peculiar feature. Its a simple 'infinite' loop with an echo and a sleep :

while [ 1 -lt 2 ]; do
echo "hello"
sleep 1
done

..and that's it. The idea was to set it running, and muck about with cntl-z and fg and bg.
Trouble is...! Before you even issue cntl-z or do anything like that, ps -few cannot see this script! The script is called test. Run it... and in another terminal window : ps -few | grep test --> nothing , only the grep itself as expected. The only thing ps can see is the sleep: ps -few | grep sleep , but of course , sleep gets a different PID each time it is run, presumably because this is not a shell "built-in." So the question is, how on earth do you detect these 'invisible' processes to kill them? Now, you may be thinking that each different 'sleep' PID always has the same parent PID in ps. This is true. So by doing ps -few | grep sleep , I can find the parent PID of the controlling bash process and kill that. But nowhere is 'test' showing up in the process list from ps. How can a system administrator go about detecting these ? Even worse if they are set up as as slow 'fork bomb' !

thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 7 2011
Added on Nov 8 2011
2 comments
314 views