Thread: Preventing a Program from exiting

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    5

    Preventing a Program from exiting

    How would i do this?
    I want a program to lay around waiting to receive signals, I dont want it to use any CPU. How would i accomplish this?

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    You could put the program to sleep with whatever function your implementation supports (sleep(), delay(), etc.)
    If you understand what you're doing, you're not learning anything.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    What types of signals? getchar() works pretty well for keyboard input.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Registered User
    Join Date
    Mar 2005
    Posts
    5
    Thanks, just what i was looking for!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. exiting program
    By ypramesh in forum C Programming
    Replies: 2
    Last Post: 04-01-2006, 03:27 PM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  3. Program exiting
    By sql.scripter in forum C Programming
    Replies: 9
    Last Post: 01-28-2006, 08:51 PM
  4. my server program auto shut down
    By hanhao in forum Networking/Device Communication
    Replies: 1
    Last Post: 03-13-2004, 10:49 PM
  5. exiting and closing a program
    By major_small in forum C++ Programming
    Replies: 10
    Last Post: 05-30-2003, 08:31 PM