home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / atari / st / tech / 4418 < prev    next >
Encoding:
Text File  |  1992-08-14  |  1.9 KB  |  46 lines

  1. Newsgroups: comp.sys.atari.st.tech
  2. Path: sparky!uunet!usc!cs.utexas.edu!torn!newshost.uwo.ca!uwovax.uwo.ca!7103_2622
  3. From: 7103_2622@uwovax.uwo.ca (Eric Smith)
  4. Subject: Re: Trapping ^C
  5. Organization: University of Western Ont, London
  6. Date: Fri, 14 Aug 1992 14:39:38 GMT
  7. Message-ID: <1992Aug14.103938.1@uwovax.uwo.ca>
  8. References: <1992Aug14.071027.24659@mnemosyne.cs.du.edu>
  9. Sender: news@julian.uwo.ca (USENET News System)
  10. Nntp-Posting-Host: hydra.uwo.ca
  11. Lines: 33
  12.  
  13. In article <1992Aug14.071027.24659@mnemosyne.cs.du.edu>, ilepore@nyx.cs.du.edu (Ian Lepore) writes:
  14. >  What's a good method of trapping a ^C from within a program and ignoring
  15. > it?
  16.  
  17. Psignal(SIGINT, SIG_IGN)...
  18.  
  19. ...oops; you're not using MiNT? Well, then it gets a lot harder :-).
  20.  
  21. Actually, I'm afraid there isn't any very good way to catch ^C in the
  22. general case. If you use the terminate handler, not only do you have to
  23. worry about Pterm0() and similar kinds of exits, but you also have to
  24. watch out for Pexec() (i.e. the program terminating may not be the one
  25. that you want to prevent from terminating).
  26.  
  27. The "best" way to do this under TOS, I think, is to not allow ^C to
  28. terminate programs at all -- do all I/O in raw mode (e.g. through the
  29. BIOS) and look for ^C's yourself. That's what we did in the original
  30. gcc library.
  31.  
  32. Next best is to require people to exit using exit() and unhook the 0x0102
  33. vector there; also, in execv() unhook the vector before running a new
  34. program. You said this wasn't an option, but perhaps you could make it
  35. an option by specifying this in the docs for your library.
  36.  
  37. Last best (IMO) is to catch trap #1 and look for Pterm() calls, as well
  38. as hooking into the 0x0102 terminate vector. This may cause problems
  39. under MultiTOS or MiNT, though, if other programs are running at the same
  40. time.
  41. --
  42. Eric R. Smith                     email:
  43. Dept. of Mathematics            eric.smith@uwo.ca
  44. University of Western Ontario
  45.  
  46.