void signal_handler(int sig) { if (sig == SIGABRT || sig == SIGTERM) { gui_term(); fprintf(stderr, "\nCaught signal %d. Bye!\n", sig); proc_cleanup(proclist); exit(EXIT_FAILURE); } }
static void sync_reset(void) { proc_cleanup(); if (sync_in) { prot_NONBLOCK(sync_in); prot_fill(sync_in); prot_free(sync_in); } if (sync_out) { prot_flush(sync_out); prot_free(sync_out); } sync_in = sync_out = NULL; #ifdef HAVE_SSL if (tls_conn) { tls_reset_servertls(&tls_conn); tls_conn = NULL; } #endif cyrus_reset_stdio(); sync_clienthost = "[local]"; if (sync_logfd != -1) { close(sync_logfd); sync_logfd = -1; } if (sync_userid != NULL) { free(sync_userid); sync_userid = NULL; } if (sync_authstate) { auth_freestate(sync_authstate); sync_authstate = NULL; } if (sync_saslconn) { sasl_dispose(&sync_saslconn); sync_saslconn = NULL; } sync_starttls_done = 0; sync_compress_done = 0; saslprops_reset(&saslprops); }
static int xsysace_remove(struct device *dev) { if (!dev) return -EINVAL; proc_cleanup(); if (old_restart) ppc_md.restart = old_restart; unregister_blkdev(xsa_major, MAJOR_NAME); del_gendisk(xsa_gendisk); blk_cleanup_queue(xsysace_queue); XSysAce_DisableInterrupt(&SysAce); free_irq(xsa_irq, NULL); iounmap((void *)(SysAce.BaseAddress)); release_mem_region(xsa_phys_addr, xsa_remap_size); return 0; /* success */ }
EXPORTED void fatal(const char* s, int code) { static int recurse_code = 0; if (recurse_code) { /* We were called recursively. Just give up */ proc_cleanup(); exit(recurse_code); } recurse_code = code; open_backups_list_close(&backupd_open_backups, 0); if (backupd_out) { prot_printf(backupd_out, "* Fatal error: %s\r\n", s); prot_flush(backupd_out); } syslog(LOG_ERR, "Fatal error: %s", s); shut_down(code); }
int main(int argc, char **argv) { struct sigaction action; int i; action.sa_handler = signal_handler; sigaction(SIGABRT, &action, NULL); sigaction(SIGTERM, &action, NULL); for(i = 1; i < argc; i++){ if(!strcmp(argv[i], "-f")){ global_force = 1; }else if(!strcmp(argv[i], "-d")){ global_debug = 1; }else{ fprintf(stderr, "Usage: %s [-f] [-d]\n" " -f: Don't prompt for lsof and strace\n" " -d: Debug mode\n" , *argv); return 1; } } extra_init(); gui_init(); proclist = proc_init(); gui_run(proclist); gui_term(); proc_cleanup(proclist); return 0; }
/** * The block function. * * block ::= const-declaration var-declaration statement. */ int block(FILE *input_file, token_type *token) { int error_code = 0; symbol *symbol; // sl, dl, ra curr_m[curr_l] += 3; error_code = emit(INC, 0, 3); if(error_code) return error_code; // const if(*token == constsym) { do { // identsym *token = get_token(input_file); if(*token != identsym) return 4; symbol = get_symbol(input_file, 1); // eqsym *token = get_token(input_file); if(*token != eqsym) { if(*token == becomessym) return 1; else return 3; } // number *token = get_token(input_file); if(*token != numbersym) return 2; if(!symbol->kind) { symbol->kind = 1; symbol->val = get_number(input_file); } else { return 29; } *token = get_token(input_file); } while(*token == commasym); if(*token != semicolonsym) return 5; *token = get_token(input_file); } // int if(*token == intsym) { int num_vars = 0; do { // identsym *token = get_token(input_file); if(*token != identsym) return 4; symbol = get_symbol(input_file, 1); if(!symbol->kind) { symbol->kind = 2; symbol->level = curr_l; symbol->addr = curr_m[curr_l]++; num_vars++; } else { return 28; } *token = get_token(input_file); } while(*token == commasym); if(*token != semicolonsym) return 5; error_code = emit(INC, 0, num_vars); if(error_code) return error_code; *token = get_token(input_file); } // proc while(*token == procsym) { // identsym *token = get_token(input_file); if(*token != identsym) return 4; // add identifier to symbol_table symbol = get_symbol(input_file, 1); if(!symbol->kind) { symbol->kind = 3; symbol->level = curr_l; symbol->addr = cx+1; /*curr_m[curr_l]++;*/ curr_l++; } else { return 28; } // semicolonsym *token = get_token(input_file); if(*token != semicolonsym) return 5; *token = get_token(input_file); // JMP over the proc code int c1 = cx; error_code = emit(JMP, 0, 0); if(error_code) return error_code; // recurse block again error_code = block(input_file, token); if(error_code) return error_code; // return error_code = emit(OPR, 0, OPR_RET); if(error_code) return error_code; // set the address for the JMP code[c1].m = cx; // some cleanup, uses the curr_l global // clears all symbols at curr_l and then decrement curr_l proc_cleanup(); // semicolonsym if(*token != semicolonsym) return 5; *token = get_token(input_file); } error_code = statement(input_file, token); if(error_code) return error_code; return error_code; }
static void __exit uptime_cleanup(void) { proc_cleanup(); }