예제 #1
0
void main()
{
    USHORT rc, Action;
    HFILE FileHandle;

    DosSetSigHandler(BrkHandler, NULL, NULL, SIGA_ACCEPT, SIG_CTRLC);
    DosSetSigHandler(BrkHandler, NULL, NULL, SIGA_ACCEPT, SIG_KILLPROCESS);
    DosSetSigHandler(BrkHandler, NULL, NULL, SIGA_ACCEPT, SIG_CTRLBREAK);

    DosSetPrty(PRTYS_PROCESS, PRTYC_IDLETIME, 0, 0);

    rc = DosOpen("Idlehlt$", &FileHandle, &Action, 0L,
                 FILE_NORMAL, FILE_OPEN, OPEN_SHARE_DENYNONE, 0L);

    if(!rc) {
        while(!ExitWhile)
            DosDevIOCtl(NULL, NULL, 0x01, 0x91, FileHandle);
        DosClose(FileHandle);
    } else {
        char buf[6], Message[36] = "HLT Driver not installed? rc=";
        char *src = buf, *dst = &Message[29];
        int len;

        utoa(rc, buf, 10);
        while(*dst++ = *src++);
        len = dst - Message;
        Message[len-1] = '\r';
        Message[len] = '\n';

        DosWrite(STDERR_FILENO, Message, len+1, &Action);
    }
}
예제 #2
0
void InitInt( void )
{
    PFNSIGHANDLER handler;
    USHORT action;

    interruptOccurred = 0;
    DosSetSigHandler( doInterrupt, &handler, &action,SIGA_ACCEPT,SIG_CTRLC);
    DosSetSigHandler( doInterrupt, &handler, &action,SIGA_ACCEPT,SIG_CTRLBREAK);
    DosError( 0x0002 ); /* disable hard-error processing */
}
예제 #3
0
void InitInt( void )
{
#ifdef _M_I86
    PFNSIGHANDLER handler;
    USHORT action;
#endif

    interruptOccurred = false;
#ifdef _M_I86
    DosSetSigHandler( doInterrupt, &handler, &action,SIGA_ACCEPT,SIG_CTRLC);
    DosSetSigHandler( doInterrupt, &handler, &action,SIGA_ACCEPT,SIG_CTRLBREAK);
#endif
    DosError( 0x0002 ); /* disable hard-error processing */
}
예제 #4
0
static void alarm_init(void)
{
    PFNSIGHANDLER pfnPrev;
    USHORT       pfAction;
    PIDINFO      pid;

    bAlarmInit = TRUE;

    if (!DosAllocSeg( ALARM_STACK, (PSEL) &selAlarmStack, SEG_NONSHARED ))
    {
      OFFSETOF(pbAlarmStack) = ALARM_STACK - 2;
      SELECTOROF(pbAlarmStack) = selAlarmStack;
      /* Create the thread */
      if (DosCreateThread( alarm_thread, &tidAlarm, pbAlarmStack ))
      {
        fprintf(stderr,"Alarm thread failed to start.\n");
        exit(1);
      }
      /* Setup the signal handler for Process Flag A */
      if (DosSetSigHandler(AlarmSignal,&pfnPrev,&pfAction,SIGA_ACCEPT,SIG_PFLG_A))
      {
        fprintf(stderr,"SigHandler Failed to install.\n");
        exit(1);
      }
      /* Save main process ID, we'll need it for triggering the signal */
      DosGetPID(&pid);
      pidMain = pid.pid;
    }
    else
      exit(1);
}
예제 #5
0
_WCRTLINK __sig_func signal( int sig, __sig_func func )
{
    __sig_func  prev_func;

    if(( sig < 1 ) || ( sig > __SIGLAST )) {
        __set_errno( EINVAL );
        return( SIG_ERR );
    }
    _RWD_abort = __sigabort;           /* change the abort rtn address */
    if( _RWD_sigtab[ sig ].os_sig_code != 0 ) {
        if( func != SIG_DFL  &&  func != SIG_ERR ) {
            if( _RWD_sigtab[ sig ].os_func == NULL ) {
                DosSetSigHandler( (PFNSIGHANDLER)break_handler,
                    &_RWD_sigtab[ sig ].os_func,
                    &_RWD_sigtab[ sig ].prev_action,
                    2,
                    _RWD_sigtab[ sig ].os_sig_code );
                __int23_exit = restore_handler;
            }
        }
    } else if( sig == SIGFPE ) {
        if( func == SIG_DFL ) {
            __restore_FPE_handler();
        } else if( func != SIG_ERR ) {
            __grab_FPE_handler();
        }
    }
    prev_func = _RWD_sigtab[ sig ].func;
    _RWD_sigtab[ sig ].func = func;
    return( prev_func );
}
예제 #6
0
static void pascal far doInterrupt( USHORT signal_argument, USHORT signal_num )
{
    PFNSIGHANDLER handler;
    USHORT action;

    signal_argument = signal_argument;
    interruptOccurred = 1;
    switch( signal_num ) {
    case SIG_CTRLBREAK:
        DosSetSigHandler( doInterrupt, &handler, &action,
                          SIGA_ACKNOWLEDGE, SIG_CTRLBREAK );
        break;
    case SIG_CTRLC:
        DosSetSigHandler( doInterrupt, &handler, &action,
                          SIGA_ACKNOWLEDGE, SIG_CTRLC );
        break;
    }
}
예제 #7
0
void __grab_int23( void )
{
    USHORT          action;

    if( handler != 0 )
        return;
    DosSetSigHandler( (PFNSIGHANDLER)break_handler, &handler, &action, 2, SIG_CTRLC );
    __int23_exit = restore_handler;
}
예제 #8
0
static VOID PASCAL FAR AlarmSignal(USHORT usSigArg,USHORT usSigNum)
{
    /*
     * this is not executed from the thread. The thread triggers Process
     * flag A which is in the main processes scope, this inturn triggers
     * (via the raise) SIGUSR1 which is defined to SIGALRM.
     */
  PFNSIGHANDLER pfnPrev;
  USHORT       pfAction;
  DosSetSigHandler(AlarmSignal,&pfnPrev,&pfAction,SIGA_ACKNOWLEDGE,SIG_PFLG_A);
  raise(SIGUSR1);
}
예제 #9
0
static void restore_handler( void )
{
    int sig;

    for( sig = 1; sig <= __SIGLAST; sig++ ) {
        if( _RWD_sigtab[ sig ].os_func != NULL ) {
                DosSetSigHandler( _RWD_sigtab[ sig ].os_func,
                                  &_RWD_sigtab[ sig ].os_func,
                                  &_RWD_sigtab[ sig ].prev_action,
                                  _RWD_sigtab[ sig ].prev_action,
                                  _RWD_sigtab[ sig ].os_sig_code );
        }
    }
    __int23_exit = __null_int23_exit;
}
예제 #10
0
static void restore_handler( void )
{
    DosSetSigHandler( handler, &handler, &action, action, SIG_CTRLC );
    handler = 0;
    __int23_exit = __null_int23_exit;
}