示例#1
0
/********************************************************************
* FUNCTION agt_signal_handler
*
* Handle an incoming interrupt signal
*
* INPUTS:
*   intr == interrupt numer
*
*********************************************************************/
void 
    agt_signal_handler (int intr)
{
    switch (intr) {
    case SIGINT:          /* control-C */
    case SIGKILL:           /* kill -9 */
    case SIGQUIT:         /* core dump */
    case SIGABRT:         /* core dump */
    case SIGILL:          /* core dump */
    case SIGTRAP:         /* core dump */
    case SIGTERM:             /* kill  */
        agt_request_shutdown(NCX_SHUT_EXIT);
        break;
    case SIGHUP:
        /* hang up treated as reset; kill -1 */
        agt_request_shutdown(NCX_SHUT_RESET);
        break;
    case SIGPIPE:
        /* broken pipe ignored */
        break;
    case SIGALRM:
        break;
    default:
        /* ignore */;
    }

} /* agt_signal_handler */
示例#2
0
/********************************************************************
*                                                                   *
*                       FUNCTION main                               *
*                                                                   *
*********************************************************************/
int main (int argc, char *argv[])
{
    status_t           res;
    boolean            showver = FALSE;
    boolean            done = FALSE;
    help_mode_t        showhelpmode;

#ifdef MEMORY_DEBUG
    mtrace();
#endif

    /* this loop is used to implement the restart command the sw image is not 
     * reloaded; instead everything is cleaned up and re-initialized from 
     * scratch. If the shutdown operation (or Ctl-C exit) is used instead of 
     * restart, then the loop will only be executed once */
    while (!done) {
        res = cmn_init( argc, argv, &showver, &showhelpmode );
    
        if (res != NO_ERR) {
            log_error( "\nnetconfd: init returned (%s)", 
                       get_error_string(res) );
            agt_request_shutdown(NCX_SHUT_EXIT);
        } else {
            if (showver) {
                show_version();
            } else if (showhelpmode != HELP_MODE_NONE) {
                help_program_module( NETCONFD_MOD, NETCONFD_CLI, showhelpmode );
                agt_request_shutdown(NCX_SHUT_EXIT);
            } else {
                res = netconfd_run();
                if (res != NO_ERR) {
                    agt_request_shutdown(NCX_SHUT_EXIT);
                }
            }
        }

        netconfd_cleanup();
        print_error_count();

        if ( NCX_SHUT_EXIT == agt_shutdown_mode_requested() ) {
            done = TRUE;
        }
    }

    print_errors();
    print_error_count();

    if ( !log_is_open() ) {
        printf("\n");
    }

#ifdef MEMORY_DEBUG
    muntrace();
#endif

    return 0;
} /* main */
示例#3
0
/********************************************************************
 * FUNCTION show_version
 *********************************************************************/
static void show_version(void)
{
    xmlChar versionbuffer[NCX_VERSION_BUFFSIZE];

    status_t res = ncx_get_version(versionbuffer, NCX_VERSION_BUFFSIZE);
    if (res == NO_ERR) {
        log_write( "\nnetconfd version %s\n", versionbuffer );
    } else {
        SET_ERROR( res );
    }
    agt_request_shutdown(NCX_SHUT_EXIT);
}