/*---------------------------------------------------------------------- Reading input somehow failed and we need to shutdown now Args: none Result: pine exits ---*/ void read_bail(void) { dprint((1, "read_bail: cleaning up\n")); /* Do not bail out on a tcp timeout, instead close the troublesome stream */ if(ps_global->tcptimeout && some_stream_is_locked()){ ps_global->read_bail = 1; return; } end_signals(1); /* * This gets rid of temporary cache files for remote addrbooks. */ completely_done_with_adrbks(); /* * This flushes out deferred changes and gets rid of temporary cache * files for remote config files. */ if(ps_global->prc){ if(ps_global->prc->outstanding_pinerc_changes) write_pinerc(ps_global, Main, WRP_NOUSER); if(ps_global->prc->rd) rd_close_remdata(&ps_global->prc->rd); free_pinerc_s(&ps_global->prc); } /* as does this */ if(ps_global->post_prc){ if(ps_global->post_prc->outstanding_pinerc_changes) write_pinerc(ps_global, Post, WRP_NOUSER); if(ps_global->post_prc->rd) rd_close_remdata(&ps_global->post_prc->rd); free_pinerc_s(&ps_global->post_prc); } sp_end(); dprint((1, "done with read_bail clean up\n")); imap_flush_passwd_cache(TRUE); end_keyboard(F_ON(F_USE_FK,ps_global)); end_tty_driver(ps_global); if(filter_data_file(0)) our_unlink(filter_data_file(0)); exit(0); }
/*---------------------------------------------------------------------- handle hang up signal -- SIGHUP Not much to do. Rely on periodic mail file check pointing. ----------------------------------------------------------------------*/ RETSIGTYPE hup_signal(void) { end_signals(1); /* don't catch any more signals */ dprint((1, "\n\n** Received SIGHUP **\n\n\n\n")); cleanup_called_from_sig_handler = 1; fast_clean_up(); #if defined(DEBUG) if(debugfile) fclose(debugfile); #endif _exit(0); /* cleaning up can crash */ }
/*---------------------------------------------------------------------- Handle signals caused by aborts -- SIGSEGV, SIGILL, etc Call panic which cleans up tty modes and then core dumps ----------------------------------------------------------------------*/ static RETSIGTYPE auger_in_signal(int sig) { char buf[100]; end_signals(1); /* don't catch any more signals */ imap_flush_passwd_cache(FALSE); snprintf(buf, sizeof(buf), "Received abort signal(sig=%d)", sig); buf[sizeof(buf)-1] = '\0'; panic(buf); /* clean up and get out */ exit(-1); /* in case panic doesn't kill us */ }
/*---------------------------------------------------------------------- handle terminate signal -- SIGTERM Not much to do. Rely on periodic mail file check pointing. ----------------------------------------------------------------------*/ RETSIGTYPE term_signal(void) { #if !defined(DOS) && !defined(OS2) end_signals(1); /* don't catch any more signals */ dprint((1, "\n\n** Received SIGTERM **\n\n\n\n")); cleanup_called_from_sig_handler = 1; fast_clean_up(); #if defined(DEBUG) && (!defined(DOS) || defined(_WINDOWS)) if(debugfile) fclose(debugfile); #endif printf(_("\n\nAlpine finished. Received terminate signal\n\n")); #endif /* !DOS */ exit(0); }
/*---------------------------------------------------------------------- Timeout when no user input for a long, long time. Treat it pretty much the same as if we got a HUP. Only difference is we sometimes turns the timeout off (when composing). ----------------------------------------------------------------------*/ void user_input_timeout_exit(int to_hours) { char msg[80]; dprint((1, "\n\n** Exiting: user input timeout (%d hours) **\n\n\n\n", to_hours)); snprintf(msg, sizeof(msg), _("\n\nAlpine timed out (No user input for %d %s)\n"), to_hours, to_hours > 1 ? "hours" : "hour"); msg[sizeof(msg)-1] = '\0'; fast_clean_up(); end_screen(msg, 0); end_titlebar(); end_keymenu(); end_keyboard(F_ON(F_USE_FK,ps_global)); end_tty_driver(ps_global); end_signals(0); #if defined(DEBUG) && (!defined(DOS) || defined(_WINDOWS)) if(debugfile) fclose(debugfile); #endif exit(0); }