The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sleep working meetbhattu UNIX for Advanced & Expert Users 2 10-29-2007 02:05 PM
Sleep less than 1 second bjorno UNIX for Dummies Questions & Answers 9 08-25-2005 12:55 AM
system sleep tamemi UNIX for Dummies Questions & Answers 8 01-02-2004 02:23 PM
Sleep under one second Scoogie Shell Programming and Scripting 5 08-14-2002 05:10 AM
sleep Anna UNIX for Dummies Questions & Answers 5 07-10-2001 08:52 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-29-2007
Registered User
 

Join Date: Mar 2007
Posts: 39
Sleep() not working

I have a function that quits a program when <ctrl>c is entered as per following code;
Code:
void quitter (void)
{
  clear ();
  mvprintw (QUITTER_ROW, QUITTER_COL, "Quitting...");
  refresh ();
  sleep (15);
  endwin ();
  exit (1);
}
This function is called thus;
Code:
signal (SIGINT, quitter);
It works, sort of. The "Quitting..." message is displayed, but only for about half a second. I can change the argument in the sleep() function all I like. It makes no difference to the amount of time "Quitting..." is displayed for. I thought my code would cause the "Quitting..." message to be displayed for 15 seconds before the execution ends. Why does it not work as intended? I tried it on another machine with the same result.
Reply With Quote
Forum Sponsor
  #2  
Old 05-29-2007
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,663
sleep in implemented with signals and now you are trying to nest handlers. Go back to your other thread and look at porter's comments about too much code in a handler. Reduce to quiter function to just setting a flag and it will work.
Reply With Quote
  #3  
Old 06-01-2007
Registered User
 

Join Date: Mar 2007
Posts: 39
I had an alarm signal interrupting the sleep() function.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0