--- os2sdk/demos/examples/signal/signal.c 2018/08/09 12:25:13 1.1 +++ os2sdk/demos/examples/signal/signal.c 2018/08/09 12:26:07 1.1.1.2 @@ -5,7 +5,7 @@ * OS/2. The signal handler is declared as a far pascal routine. It * expects two paramters on the stack: the signal number and, optionally, * a user defined argument. The latter has meaning only when the signal was - * generated by a DOSFLAGPROCESS api call. + * generated by a DosFlagProcess api call. * * In general the signal handler can be thought of as an interrupt to * the current running thread of a process. Thread scheduling is still @@ -13,51 +13,44 @@ * * After a signal has been caught, the handler must "acknowledge" the signal * before a second one can be handled. + * + * Created by Microsoft Corp. 1986 */ -#include -#include -#include +#define INCL_DOSSIGNALS +#define INCL_DOSMISC -#define SIGINTR 1 -#define SIGTERM 3 -#define SIGBREAK 4 -#define CATCH_SIG 2 -#define SIG_ACK 4 +#include +#include +#include -void pascal far sig_handler(); +void APIENTRY sig_handler(); void main() { - char c; - void (pascal far *address)(); - unsigned oldaction; - unsigned result; - - if (result = DOSSETSIGHANDLER(sig_handler, - (unsigned long far *) &address, - (unsigned far *) &oldaction, - CATCH_SIG, SIGINTR)) + char c; + PFNSIGHANDLER address; + USHORT oldaction; + unsigned result; + + if (result = DosSetSigHandler(sig_handler, &address, + &oldaction, SIGA_ACCEPT, SIGA_IGNORE)) fprintf(stderr,"dossetsighandler failed %d\n", result); - if (result = DOSSETSIGHANDLER(sig_handler, - (unsigned long far *) &address, - (unsigned far *) &oldaction, - CATCH_SIG, SIGTERM)) + if (result = DosSetSigHandler(sig_handler, &address, + &oldaction, SIGA_ACCEPT, SIGA_ERROR)) fprintf(stderr,"dossetsighandler failed %d\n", result); - if( DOSGETMACHINEMODE( &c)) - if (result = DOSSETSIGHANDLER(sig_handler, - (unsigned long far *) &address, - (unsigned far *) &oldaction, - CATCH_SIG, SIGBREAK)) - + if( DosGetMachineMode( &c)) + if (result = DosSetSigHandler(sig_handler, &address, + &oldaction, SIGA_ACCEPT, + SIGA_ACKNOWLEDGE )) fprintf(stderr,"dossetsighandler failed %d\n", result); do - printf("Type an SPACE to terminate demo\n"); + printf("Type a SPACE to terminate demo\n"); while(getchar() != 0x20); fprintf(stderr,"Program terminating\n"); @@ -71,19 +64,18 @@ void main() { * a high priority thread and always snoozing. Of course, the * acknowlegement should be the first thing done in the handler. */ -void pascal far sig_handler(sig_arg, sig_num) -unsigned sig_arg, sig_num; +void APIENTRY sig_handler(sig_arg, sig_num) +USHORT sig_arg, sig_num; { - unsigned signum, sigarg; - long address; + USHORT signum, sigarg; + PFNSIGHANDLER address; int count; fprintf(stderr, "signum %u sigarg %u\n", sig_num, sig_arg); - if (count = DOSSETSIGHANDLER( (void (far *)())0L, - (unsigned long far *) &address, - (unsigned far *) &sigarg, - SIG_ACK, sig_num)) + if (count = DosSetSigHandler( (void (pascal far *)())0L, + &address, + &sigarg, SIGA_ACKNOWLEDGE, sig_num)) fprintf(stderr,"dossetsighandler failed %d\n", count); }