LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

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


Hello!

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, 10:50 AM   #2
JoeDuncan
Member
 
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, 01:39 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 7,151

Rep: Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203Reputation: 2203
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, 01:45 PM   #4
itz2000
Member
 
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, 03:49 AM   #5
Feyd-Rautha
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
Code:
#!/bin/bash

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


Reply


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-14-2006 12:40 AM
Process killing script owix Linux - General 2 07-19-2005 12:08 PM
Killing X Blindly (by Script)? negface Slackware 38 10-01-2004 10:03 PM
php script to kill the popups from no-ip.com _MD_ Linux - General 1 04-15-2004 11:52 AM
Kill -9 not killing application, connected with cdrom busy error? vdemuth Linux - Software 5 04-11-2004 03:33 PM


All times are GMT -5. The time now is 10:29 PM.

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