home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / programm / 4405 < prev    next >
Encoding:
Internet Message Format  |  1992-08-21  |  1.7 KB

  1. Path: sparky!uunet!mcsun!ieunet!!bsullivn
  2. From: bsullivn@sc.sni.ie (Bryan O'Sullivan)
  3. Newsgroups: comp.unix.programmer
  4. Subject: Re: How to restart a process after the machine is up.
  5. Message-ID: <164@sc.sni.ie>
  6. Date: 18 Aug 92 09:46:33 GMT
  7. Article-I.D.: sc.164
  8. References: <SULLIVAN.92Aug17154930@liz.cs.rose-hulman.edu>
  9. Reply-To: bryan@sc.sni.ie
  10. Organization: Siemens-Nixdorf Software Development Centre, Dublin
  11. Lines: 26
  12. X-Newsreader: Tin 1.1 PL3
  13.  
  14.  
  15.  
  16. sullivan@cs.rose-hulman.edu (Fred Sullivan) writes:
  17.  
  18. : A trick which may or may not be applicable.  If the current state of the 
  19. : process is easily saved (say by writing to a file) you can write a signal
  20. : handler for an unused signal (e.g. SIGUSR1), which dumps the state.
  21.  
  22. : When the program starts up, have it read its starting state from the file.
  23.  
  24. : When you want to shut down the machine, just send the process a signal.  I
  25. : once used this technique to keep a program running for several months.
  26.  
  27. Possibly a better approach: when a UNIX system is being brought down to
  28. single-user mode to be powered down, the script that handles this (on
  29. SVR4 at least) sends a SIGTERM to all user processes and gives them
  30. around 5 seconds of grace to save state or clean thingss up before
  31. sending them a non-maskable SIGKILL.  You might do better to write a
  32. SIGTERM handler for your application; it avoids the need for
  33. special-casing.
  34.  
  35.     -- Bryan
  36.  
  37. -- 
  38. Bryan O'Sullivan                                             +353-1-767551 x225
  39. Siemens-Nixdorf Informationssysteme AG                          bryan@sc.sni.ie
  40. Software Development Centre                    "Theory like mist on eyeglasses.
  41. Dublin                                          Obscure facts." -- Charlie Chan
  42.