Beispiel #1
0
void SSHDefaultSigHandler (int signum)
{
    int         retVal;

    switch (signum)
    {
        case SIGHUP:
            // user wants us to change the verbosity setting
            retVal = wvutilsToggleVerbosity ();
            radMsgLog (PRI_STATUS, "wviewsshd: SIGHUP - toggling log verbosity %s",
                       ((retVal == 0) ? "OFF" : "ON"));

            radProcessSignalCatch(signum, SSHDefaultSigHandler);
            return;

        case SIGBUS:
        case SIGFPE:
        case SIGSEGV:
        case SIGXFSZ:
        case SIGSYS:
            // unrecoverable radProcessSignalCatch- we must exit right now!
            radMsgLog (PRI_CATASTROPHIC, 
                       "wviewsshd: recv unrecoverable signal %d: aborting!",
                       signum);
            if (!sshWork.exiting)
            {
                radTimerDelete (sshWork.timer);
                sshSysExit (&sshWork);
                radProcessExit ();
                radSystemExit (WVIEW_SYSTEM_ID);
            }
            abort ();
        
        case SIGCHLD:
            // it is normal behavior to have children finishing up
            wvutilsWaitForChildren();
            radProcessSignalCatch(signum, SSHDefaultSigHandler);
            break;

        default:
            // we can allow the process to exit normally...
            if (sshWork.exiting)
            {
                radProcessSignalCatch(signum, SSHDefaultSigHandler);
                return;
            }
        
            radMsgLog (PRI_HIGH, "wviewsshd: recv signal %d: exiting!", signum);
        
            sshWork.exiting = TRUE;
            radProcessSetExitFlag ();
        
            radProcessSignalCatch(signum, SSHDefaultSigHandler);
            break;
    }

    return;
}
Beispiel #2
0
static void defaultSigHandler (int signum)
{
    int         retVal;

    switch (signum)
    {
        case SIGHUP:
            // user wants us to change the verbosity setting
            retVal = wvutilsToggleVerbosity ();
            radMsgLog (PRI_STATUS, "wviewd: SIGHUP - toggling log verbosity %s",
                       ((retVal == 0) ? "OFF" : "ON"));

            radProcessSignalCatch(signum, defaultSigHandler);
            return;

        case SIGPIPE:
            // we have a far end socket disconnection, we'll handle it in the
            // "read/write" code
            radProcessSignalCatch(signum, defaultSigHandler);
            break;

        case SIGBUS:
        case SIGFPE:
        case SIGSEGV:
        case SIGXFSZ:
        case SIGSYS:
            // unrecoverable radProcessSignalCatch- we must exit right now!
            radMsgLog (PRI_CATASTROPHIC, "wviewd: recv sig %d: shutting down!", signum);
            abort ();

        case SIGCHLD:
            wvutilsWaitForChildren();
            radProcessSignalCatch(signum, defaultSigHandler);
            return;

        default:
            // we can allow the process to exit normally...
            if (wviewdWork.exiting)
            {
                radProcessSignalCatch(signum, defaultSigHandler);
                return;
            }

            radMsgLog (PRI_HIGH, "wviewd: recv sig %d: exiting!", signum);

            wviewdWork.exiting = TRUE;
            radProcessSetExitFlag ();

            radProcessSignalCatch(signum, defaultSigHandler);
            break;
    }

    return;
}
Beispiel #3
0
// station-supplied function to indicate data is available on the station
// interface medium (serial or ethernet) -
// It is the responsibility of the station interface to read the data from the
// medium and process appropriately. The data does not have to be read within
// the context of this function, but may be used to stimulate a state machine.
// -- Synchronous --
//
// Returns: N/A
//
void stationDataIndicate (WVIEWD_WORK *work)
{
    int         retVal, done = FALSE;

    if (virtualProtocolDataIndicate(work) == ERROR_ABORT)
    {
        // We need to try to reconnect:
        radMsgLog (PRI_HIGH, "VIRTUAL: remote station lost - retrying...");
        virtualProtocolExit(work);
        (*(work->medium.exit))(&work->medium);

        while (! done && ! work->exiting)
        {
            retVal = RestoreConnection(work);
            if (retVal == ERROR_ABORT)
            {
                radMsgLog (PRI_HIGH, "VIRTUAL: restore connection failed - exiting");
                radProcessSetExitFlag();
                done = TRUE;
            }
            else if (retVal == OK)
            {
                radMsgLog (PRI_HIGH, "VIRTUAL: restore connection success");
                virtualProtocolInit(work);
                done = TRUE;
            }
            else
            {
                radMsgLog (PRI_HIGH, "VIRTUAL: try again in 15 seconds to restore connection.");
                radUtilsSleep(15000);
            }
        }
    }

    return;
}
Beispiel #4
0
static void defaultSigHandler (int signum)
{
    int         retVal;

    switch (signum)
    {
    case SIGHUP:
        // user wants us to change the verbosity setting
        retVal = wvutilsToggleVerbosity ();
        radMsgLog (PRI_STATUS, "wvpmond: SIGHUP - toggling log verbosity %s",
                   ((retVal == 0) ? "OFF" : "ON"));

        radProcessSignalCatch(signum, defaultSigHandler);
        return;

    case SIGPIPE:
        // we have a far end socket disconnection, we'll handle it in the
        // "read/write" code
        radProcessSignalCatch(signum, defaultSigHandler);
        break;

    case SIGILL:
    case SIGBUS:
    case SIGFPE:
    case SIGSEGV:
    case SIGXFSZ:
    case SIGSYS:
        // unrecoverable radProcessSignalCatch- we must exit right now!
        radMsgLog (PRI_CATASTROPHIC,
                   "wvpmond: recv unrecoverable signal %d: aborting!",
                   signum);
        abort ();

    case SIGCHLD:
        wvutilsWaitForChildren();
        radProcessSignalCatch(signum, defaultSigHandler);
        return;

    default:
        if (procmonWork.exiting)
        {
            radProcessSignalCatch(signum, defaultSigHandler);
            return;
        }

        procmonWork.exiting = TRUE;
        radProcessSetExitFlag ();

        // can we allow the process to exit normally?
        if (!procmonWork.inMainLoop)
        {
            // NO! - we gotta bail here!
            radMsgLog (PRI_HIGH, "wvpmond: recv signal %d: exiting now!", signum);
            radMsgRouterExit ();
            procmonSysExit (&procmonWork);
            radProcessExit ();
            radSystemExit (WVIEW_SYSTEM_ID);
            exit (0);
        }

        // we can allow the process to exit normally...
        radMsgLog (PRI_HIGH, "wvpmond: recv signal %d: exiting!", signum);

        radProcessSignalCatch(signum, defaultSigHandler);
        break;
    }

    return;
}
Beispiel #5
0
static void defaultSigHandler (int signum)
{
    int         retVal;

    switch (signum)
    {
        case SIGHUP:
            // user wants us to change the verbosity setting
            retVal = wvutilsToggleVerbosity ();
            radMsgLog (PRI_STATUS, "wvalarmd: SIGHUP - toggling log verbosity %s",
                       ((retVal == 0) ? "OFF" : "ON"));

            radProcessSignalCatch(signum, defaultSigHandler);
            return;

        case SIGPIPE:
            // we have a far end socket disconnection, we'll handle it in the
            // "read/write" code
            alarmsWork.sigpipe = TRUE;
            radProcessSignalCatch(signum, defaultSigHandler);
            break;

        case SIGCHLD:
            wvutilsWaitForChildren();
            radProcessSignalCatch(signum, defaultSigHandler);
            break;

        case SIGILL:
        case SIGBUS:
        case SIGFPE:
        case SIGSEGV:
        case SIGXFSZ:
        case SIGSYS:
            // unrecoverable radProcessSignalCatch- we must exit right now!
            radMsgLog (PRI_CATASTROPHIC, 
                       "wvalarmd: recv catastrophic signal %d: aborting!", 
                       signum);
            abort ();

        default:
            // can we allow the process to exit normally?
            if (!alarmsWork.inMainLoop)
            {
                // NO! - we gotta bail here!
                statusUpdateMessage("wvalarmd: recv signal exiting now!");
                radMsgLog (PRI_HIGH, "wvalarmd: recv signal %d: exiting now!", signum);
                if (alarmsWork.dataFeedServer)
                    radSocketDestroy (alarmsWork.dataFeedServer);

                radMsgRouterExit ();
                alarmsSysExit (&alarmsWork);
                radProcessExit ();
                radSystemExit (WVIEW_SYSTEM_ID);
                exit (1);                
            }

            // we can allow the process to exit normally...
            statusUpdateMessage("wvalarmd: recv catastrophic signal exiting gracefully!");
            radMsgLog (PRI_HIGH, "wvalarmd: recv signal %d: exiting gracefully!", signum);

            alarmsWork.exiting = TRUE;
            radProcessSetExitFlag ();

            radProcessSignalCatch(signum, defaultSigHandler);
            break;
    }

    return;
}