Since I have a menu program that waits for time to pass with no input I need to kill processes it creates when it does its thing. I will try to explain.
When I run the menu program it puts a sleep in the procces list. I have a pid and a ppid. That tells me the current sleep. If I hit enter or do a menu function when it returns to the main menu program I get a new pid and the old pid and ppid change. I want to go and kill the old pid if the ppid goes to 1. How can I do this?
Example here I'm running the menu program.
systrain2 :/ >ps -ef | grep sleep | awk '{print $2,$3}'
18878 18090
As you can see it has a good pid and ppid
If I hit enter or go to a menu function and come back I get a new pid ppid and the old pid ppid changes to 1
systrain2 :/ >ps -ef | grep sleep | awk '{print $2,$3}'
12066 13104
16704 1
18098 1
18878 1
This will build till the timeout happens. How can I based on this info do a kill on all sleep ppid's that go to 1 that way only the new one is active. I have manually killed the ones with ppid of 1 and the menu still works.
Thanks for any ideas...
When I run the menu program it puts a sleep in the procces list. I have a pid and a ppid. That tells me the current sleep. If I hit enter or do a menu function when it returns to the main menu program I get a new pid and the old pid and ppid change. I want to go and kill the old pid if the ppid goes to 1. How can I do this?
Example here I'm running the menu program.
systrain2 :/ >ps -ef | grep sleep | awk '{print $2,$3}'
18878 18090
As you can see it has a good pid and ppid
If I hit enter or go to a menu function and come back I get a new pid ppid and the old pid ppid changes to 1
systrain2 :/ >ps -ef | grep sleep | awk '{print $2,$3}'
12066 13104
16704 1
18098 1
18878 1
This will build till the timeout happens. How can I based on this info do a kill on all sleep ppid's that go to 1 that way only the new one is active. I have manually killed the ones with ppid of 1 and the menu still works.
Thanks for any ideas...