Esempio n. 1
0
int
crm_exit(int rc)
{
    mainloop_cleanup();

#if HAVE_LIBXML2
    crm_trace("cleaning up libxml");
    crm_xml_cleanup();
#endif

    crm_trace("exit %d", rc);
    qb_log_fini();

    free(crm_short_options);
    free(crm_system_name);

    exit(ABS(rc)); /* Always exit with a positive value so that it can be passed to crm_error
                    *
                    * Otherwise the system wraps it around and people
                    * have to jump through hoops figuring out what the
                    * error was
                    */
    return rc;     /* Can never happen, but allows return crm_exit(rc)
                    * where "return rc" was used previously - which
                    * keeps compilers happy.
                    */
}
Esempio n. 2
0
crm_exit_t
crm_exit(crm_exit_t rc)
{
    /* A compiler could theoretically use any type for crm_exit_t, but an int
     * should always hold it, so cast to int to keep static analysis happy.
     */
    if ((((int) rc) < 0) || (((int) rc) > CRM_EX_MAX)) {
        rc = CRM_EX_ERROR;
    }

    mainloop_cleanup();
    crm_xml_cleanup();

    qb_log_fini();
    crm_args_fini();

    if (crm_system_name) {
        crm_info("Exiting %s " CRM_XS " with status %d", crm_system_name, rc);
        free(crm_system_name);
    } else {
        crm_trace("Exiting with status %d", rc);
    }

    exit(rc);
    return rc;     /* Can never happen, but allows return crm_exit(rc)
                    * where "return rc" was used previously - which
                    * keeps compilers happy.
                    */
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
    mrp_mainloop_t *ml;

    mrp_clear(&cfg);
    parse_cmdline(&cfg, argc, argv);

    mrp_log_set_mask(cfg.log_mask);
    mrp_log_set_target(cfg.log_target);

    ml = mainloop_create(&cfg);

    if (ml == NULL)
        fatal("failed to create main loop.");

    dbus_test.ml = ml;
    setup_dbus_tests(ml);
    ml = dbus_test.ml;

    setup_timers(ml);
    setup_io(ml);
    setup_signals(ml);
    MRP_UNUSED(setup_deferred);   /* XXX TODO: add deferred tests... */

#ifdef GLIB_ENABLED
    if (cfg.mainloop_type != MAINLOOP_GLIB && cfg.mainloop_type != MAINLOOP_QT) {
        if (cfg.ngio > 0 || cfg.ngtimer > 0)
            glib_pump_setup(ml);
    }

    setup_glib_io();
    setup_glib_timers();
#endif

    if (mrp_add_timer(ml, 1000, check_quit, NULL) == NULL)
        fatal("failed to create quit-check timer");

    setup_wakeup(ml);

    mainloop_run(&cfg);

    check_io();
    check_timers();
    check_signals();

#ifdef GLIB_ENABLED
    check_glib_io();
    check_glib_timers();
#endif

    if (dbus_test.client != 0)
        close(dbus_test.pipe[1]);   /* let the client continue */

    check_dbus();

#ifdef GLIB_ENABLED
    if (cfg.mainloop_type != MAINLOOP_GLIB) {
        if (cfg.ngio > 0 || cfg.ngtimer > 0)
            glib_pump_cleanup();
    }
#endif

    cleanup_wakeup();

    mainloop_cleanup(&cfg);
}