LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-27-2003, 03:11 PM   #1
mister_math
Member
 
Registered: Feb 2003
Location: /USA/IL/Chicago
Distribution: Ubuntu 5.10
Posts: 37

Rep: Reputation: 15
Shutting down while in "sleep"


I recently wrote a small shell script to:
1) Check my CPU's temperature and if it's too hot
2) Kill the offending program taking up CPU cycles
3) Wait 3 minutes for the CPU to cool down
4) Restart the program

My question is this: What happens if I shut down my computer while this shell script is in the "sleep" portion of the program? (I run this as a cron job) I can't seem to locate the answer to this question on the Internet, which maybe means it's a non-issue, but I just wanted to check.
 
Old 08-01-2003, 01:10 PM   #2
MacKtheHacK
Member
 
Registered: Jul 2003
Location: Boston, MA, USA
Distribution: RedHat, SuSE, Gentoo, Slackware, Mandrake ...
Posts: 111

Rep: Reputation: 15
It's pretty much a non-issue. The shell running that script will be killed off during the shutdown process. When you do a shutdown, all running processes will be sent a SIGINT signal to tell them that they should stop whatever they are doing, clean up and exit. About five seconds later, any process that hasn't obeyed will be summarily shot. That is, they are sent the SIGKILL signal, which they cannot trap or ignore. In this way, all processes are given a chance to do a nice clean termination. If they don't cooperate, the system kills them off.

In your case, you've got two processes running: your shell that's running the script, and its child process running sleep(1). They will both receive the SIGINT at about the same time. The sleep will wake up and exit. The shell will just immediately exit, before it even tries to look at the exit status of the sleep it spawned. So it won't have the opportunity to try to restart your program, if that's what you're worried about.
 
  


Reply



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
"echo 3 > /proc/acpi/sleep" does nothing - ?? achallenger1 Linux - Newbie 6 08-02-2005 11:28 PM
How do I set my laptop to "standby/sleep"? rcbarnes Linux - Laptop and Netbook 0 11-15-2004 02:37 PM
"Power down" hangs when shutting Mandrake 10 DJ FlowFX Mandriva 7 08-24-2004 12:45 PM
monitor in supsend/sleep mode... can't "wake" it up schbond Linux - Hardware 2 09-15-2003 12:03 AM
disable "shutting down eth0" from init-script? tyrann Linux - General 3 07-13-2003 12:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:57 AM.

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
Open Source Consulting | Domain Registration