david@squid.UUCP (07/30/88)
From squid!david Fri Jul 29 22:17 CDT 1988 remote from occrsh From: occrsh!squid!david (David Drexler) Date: Fri, 29 Jul 88 22:17:05 CDT Message-Id: <88210226A9@squid.UUCP> Subject: ssignal() vs signal() PLEASE NOTE: use the address at the end to send mail to me. I tried to send this privately, but it bounced with a "forwarding disallowed" error message from att. I suspect that will change a lot of the rules about whether to post responses, or send them to the author for summarizing. If you can't get direct mail to the author, what are you supposed to do? Turbo Cretin does not implement the unixoid signal() function. The ssignal() is something quite different. Yeah, I got bit by this one, too. The following is exerpted from Norton Guide (a complete on-line stayres manual, well worth the price!!) ssignal() Implement Software Signals #include <signal.h> int (*ssignal(sig,action))(); int sig; Type of signal int (*action)(); Action function/Constant ssignal() is used to establish an action routine for servicing a signal. Software signals are associated with integers in the range from 1 to 15. 'sig' is a number identifying the type of signal for which an action is established. 'action' is either the name of a user-defined action function or one of the constants SIG_DFL (default) or SIG_IGN (ignore) (defined in <signal.h>). If the action function has been established for 'sig', then that action is reset to SIG_DFL, and the action function is entered with 'sig'. Returns: The action previously established or SIG_DFL, if the signal number is illegal. gsignal() Software Signals #include <signal.h> int gsignal(sig); int sig; Type of signal gsignal() implements a software-signaling facility. Software signals are integers ranging from 1 to 15. gsignal() raises the signal given by 'sig' and executes the action routine. Returns: The value returned to gsignal() by the action function. The return values for actions assigned to 'sig' are: ACTION RETURN SIG_IGN 1 SIG_DFL 0 Illegal value or 0 no action specified In all cases, gsignal() takes no action other than returning a value. The ssignal() is like signal() in that you can specify a vector to jump to on a specific event. The difference is that the "events" are ALL user defined, and activated by gsignal(). For example: #include <stdio.h> #include <signal.h> fubar() { puts( "Here we are in fubar()" ) ; } main() { ssignal( 1, fubar ) ; gsignal( 1 ) ; } ...does what you might expect, prints "Here we are in fubar()". Despite the rhetoric in Norton (which does contain a few minor inaccuracies just to keep you on your toes), do note that once you call gsignal(), you have to reset the vector with ssignal() again. There are a couple ways to snarf a ^C. With input routines, the nicest way to do it is to use input functions that ignore it, and just look for the code yourself. Also, there is the ctrlbrk() function. I don't like it because you get the "^C" printed on the screen. Norton says (and I qoute :-) ctrlbrk() Set Control-Break Handler #include <dos.h> void ctrlbrk(fptr); int (*fptr)(void); Handler function ctrlbrk() sets a new control-break handler function pointed to by 'fptr'. The interrupt vector 0x23 is modified to call the named function. ctrlbrk() establishes a DOS interrupt handler that calls the named function indirectly. The handler function may perform any number of operations and system calls. The handler function does not have to return; it may use longjmp() to return to any point in the program. Returns: ctrlbrk() returns nothing. 0 is returned by the handler function to abort the current program. Any other value causes the program to resume execution. It is the only Turbo Cretin function I know about that actually snarfs a real interrupt. It isn't too awful hard to steal interrupts on your own, as long as you know what you're doing. There are a lot of rules, and woe unto you if you break any of them. BTW, I run a bbs that has a lot of Turbo Cretin code on it. The board is SOURCEry System bbs, 405-728-2463 (2400bps), in Oklahoma City. Happy hacking! --david +---+ {the known world}!att \ FidoNet 1:19/1 +---+ | | lll-winken!spl1 ->-!occrsh!squid!david | | +---+ uokmax.ecn.uoknor.edu / <Squid> UU/FidoGate +---+
pk-tle@nada.kth.se (Tommy Levitte) (08/01/88)
>The ssignal() is like signal() in that you can specify a vector to jump >to on a specific event. The difference is that the "events" are ALL user >defined, and activated by gsignal(). [...] Are you real sure ??? If you take a look at the file 'signal.h', you can find SIGINT, and some other words defined for Float Exception, Memory Exception and some others. -- ------------------------------------------------------------------------------- Tommy Levitte (pk-tle@draken.nada.kth.se or gizmo@kicki.stacken.kth.se) -------------------------------------------------------------------------------