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