Beispiel #1
0
void
watchdog_start(glite_renewal_core_context ctx)
{
   struct sigaction sa;
   int force_renewal;
   int count = 0, num;
   
   memset(&sa,0,sizeof(sa));
   sa.sa_handler = register_signal;
   sigaction(SIGUSR1, &sa, NULL);
   sigaction(SIGINT,&sa,NULL);
   sigaction(SIGQUIT,&sa,NULL);
   sigaction(SIGTERM,&sa,NULL);
   sigaction(SIGPIPE,&sa,NULL);

   while (count < RENEWAL_COUNTS_MAX && !die) {
       received_signal = -1;
       sleep(60 * 5);
       force_renewal = (received_signal == SIGUSR1) ? 1 : 0;
       if (die)
	  break;
       /* XXX uninstall signal handler ? */
       renewal(ctx, force_renewal, &num);
       count += num;
   }
   glite_renewal_log(ctx, LOG_DEBUG, "Terminating after %d renewal attempts", count);
   exit(0);
}
Beispiel #2
0
int main(int argc, char *argv[])
{
    char account_id[ACCOUNT_LEN+1];
    menu_options_e current_option;

    /* Initian account_id. */
    memset(account_id, '\0', sizeof(account_id));
    current_option = mo_login; /* make sure current_option not equal mo_exit. */
    announce();
    database_initialize();

    /* Now we wait for user to input command. */
    while (current_option != mo_exit) {
        current_option = show_menu(account_id);

        switch(current_option) {
            case mo_new:
                create_new_account();
                break;
            case mo_reset:
                reset_passwd();
                break;
            case mo_loss:
                report_loss();
                break;
            case mo_login:
                login(account_id);
                break;
            case mo_query:
                query(account_id);
                break;
            case mo_store:
                store_money(account_id);
                break;
            case mo_draw:
                draw_money(account_id);
                break;
            case mo_renewal:
                renewal(account_id);
                break;
            case mo_change_passwd:
                change_passwd(account_id);
                break;
            case mo_logout:
                logout(account_id);
                break;
            case mo_exit:
            case mo_invalid:
            default:
                break;
        } /* switch */
    } /* while */

    database_close();
    exit(EXIT_SUCCESS);
}