| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | BCOS2 signal() |
-=> Quoting Paul Edwards to Phil Crown <=-
PE> 2. The example program in the Borland book on how to use signal()
PE> doesn't compile, and obviously when you're trying to use it in
PE> real life (e.g. trying to recompile zip/unzip I think it was), it
PE> fails.
PC> The below example from BCOS2 v2.0, as you posted, it does not compile, but
PC> I made two changes below and it compiles... and.. works! :-)
PE> The bug was fixed in BCOS2 1.5. Are you sure the example on
PE> signal doesn't compile?
PC> //signal(SIGFPE, (void (cdecl *) (int)) catcher); // won't compile
PC> signal(SIGINT, catcher); // will compile, SIGINT
Yes, I'm sure the example from the online docs doesn't compile. I've tried
it several times. After I removed all the casting it compiles and works.
I was wondering, because P (freeware X, Y, Zmodem which comes with source
for the loader, not the protocol) calls signal(SIGINT,...) and I've
successfully compiled it under BCOS2, but it P doesn't do any casting.
The example from BCOS2 is even wrong, it calls SIGFPE which is described
below, but the code is checking for Ctrl-C. SIGFPE also works, if you
change the example to produce a divide by 0 error.
SIGFPE Arithmetic error caused by division by 0, invalid operation,
and the like. Default action is program termination.
SIGINT CTRL-C interrupt. Default action is program termination.
/* This example installs a signal handler routine to be run when Ctrl-Break
is pressed. */
#include
#include
#include
void catcher(void)
{
printf("\nNow in break routine\n");
exit(1);
}
int main(void) {
signal(SIGFPE, (void (cdecl *) (int)) catcher); // should be SIGINT
for (;;)
printf("\nIn main() program\n");
}
phil.crown{at}bluecafe.com
--- Blue Wave/Max v2.22a
* Origin: * MacSavvy * Dallas * Mac * OS/2 * (214)250-4479 * (1:124/1208)SEEN-BY: 270/101 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407 SEEN-BY: 712/515 517 628 713/888 800/1 7877/2809 @PATH: 124/1208 1 396/1 270/101 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.