Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This 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!


  Search this Thread
Old 12-06-2005, 06:19 AM   #1
LQ Newbie
Registered: Dec 2005
Posts: 13

Rep: Reputation: 0
Killing the sleeping script does not kill sleep


I'm having some trouble with a simple daemon I'm working on.
This bash script only has to sleep a lot of time and then do a few things.
The problem is: when other processes kill the daemon (with killall), it does die, but the sleep process continues running.
After several executions and killings of the script, my ps gets filled with "sleep 7200" stuff

How could I solve this problem?

Thank you!
Old 12-06-2005, 09:50 AM   #2
Registered: Aug 2003
Location: Ottawa
Distribution: Redhat 5.2, 6.0, 6.1, Mandrake 7.2, 8.0, 9.1, 9.2, 10.0, Gentoo, Debian 3.1r0
Posts: 224

Rep: Reputation: 30
You could try having your script do "pstree -p | grep sleep", pull out the PID and kill the sleep process when you don't need it...
Old 12-06-2005, 12:39 PM   #3
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3166Reputation: 3166Reputation: 3166Reputation: 3166Reputation: 3166Reputation: 3166Reputation: 3166Reputation: 3166Reputation: 3166Reputation: 3166Reputation: 3166
I'm not sure how you've organized these processes... You don't tell us anything about how you built the code.

If the sleeping process is a child of the process that you are killing, then it should die as well.

If the sleeping process has been spawned as an entirely separate process from the one that originally created it, then it won't be killed with its original parent.

Usually, servers are responsible for their children. Upon receipt of a SIGTERM, they terminate the child-processes then terminate themselves. This enables them to control the timing in which these operations take place... so that the parent won't "pull the rug out from under" a child process. (This would be the sort of thing that never happens during development testing, and then happens every time at the customer site.)
Old 12-06-2005, 12:45 PM   #4
Registered: Jul 2005
Distribution: Fedora fc4, fc7, Mandrake 10.1, mandriva06, suse 9.1, Slackware 10.2, 11.0, 12.0,1,2 (Current)]
Posts: 732

Rep: Reputation: 30
don't ya can kill the sleeping process? :S
Old 12-07-2005, 02:49 AM   #5
LQ Newbie
Registered: Dec 2005
Posts: 13

Original Poster
Rep: Reputation: 0
When I killall the script with the sleep command running, I find that the sleep survives. Here it is...

WARNING: noob code follows

if [ $# = 1 ]
	sleep $1
	touch /var/flags/ppp_disconnect
	echo Please specify timeout as parameter


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
killing a hung up process with a script lockejr Linux - General 2 04-13-2006 11:40 PM
Process killing script owix Linux - General 2 07-19-2005 11:08 AM
Killing X Blindly (by Script)? negface Slackware 38 10-01-2004 09:03 PM
php script to kill the popups from _MD_ Linux - General 1 04-15-2004 10:52 AM
Kill -9 not killing application, connected with cdrom busy error? vdemuth Linux - Software 5 04-11-2004 02:33 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:49 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration