void do_halt (int error) { int retval; if (daemonize) { return; } if (!readline_disabled) { rl_free_line_state (); rl_cleanup_after_signal (); } if (write (1, "halt\n", 5) < 0) { // Sad thing } if (unix_socket) { unlink (unix_socket); } if (usfd > 0) { close (usfd); } if (sfd > 0) { close (sfd); } if (exit_code) { retval = exit_code; } else { retval = error ? EXIT_FAILURE : EXIT_SUCCESS; } exit (retval); }
JNIEXPORT void JNICALL Java_org_gnu_readline_Readline_cleanupReadlineImpl (JNIEnv *env, jclass theClass) { #if defined JavaReadline && !defined MAC_OS rl_free_line_state(); rl_cleanup_after_signal(); #endif }
void CliRunnable::stop(void) { _stop=true; rl_free_line_state(); rl_cleanup_after_signal(); log("Shutting down CLI..."); }
static char * readline_until_enter_or_signal(const char *prompt, int *signal) { char * not_done_reading = ""; fd_set selectset; *signal = 0; #ifdef HAVE_RL_CATCH_SIGNAL rl_catch_signals = 0; #endif rl_callback_handler_install (prompt, rlhandler); FD_ZERO(&selectset); completed_input_string = not_done_reading; while (completed_input_string == not_done_reading) { int has_input = 0, err = 0; while (!has_input) { struct timeval timeout = {0, 100000}; /* 0.1 seconds */ /* [Bug #1552726] Only limit the pause if an input hook has been defined. */ struct timeval *timeoutp = NULL; if (PyOS_InputHook) timeoutp = &timeout; FD_SET(fileno(rl_instream), &selectset); /* select resets selectset if no input was available */ has_input = select(fileno(rl_instream) + 1, &selectset, NULL, NULL, timeoutp); err = errno; if(PyOS_InputHook) PyOS_InputHook(); } if (has_input > 0) { rl_callback_read_char(); } else if (err == EINTR) { int s; #ifdef WITH_THREAD PyEval_RestoreThread(_PyOS_ReadlineTState); #endif s = PyErr_CheckSignals(); #ifdef WITH_THREAD PyEval_SaveThread(); #endif if (s < 0) { rl_free_line_state(); rl_cleanup_after_signal(); rl_callback_handler_remove(); *signal = 1; completed_input_string = NULL; } } } return completed_input_string; }
void ping(int) { DCOPClient *client = KApplication::dcopClient(); if (!client->registeredApplications().contains(kstName)) { printf("%s", _T("Kst application process has terminated.\n")); rl_cleanup_after_signal(); exit(ERR_KST_TERMINATED); } }
static void jack_shutdown(void *arg) { #if defined(RL_READLINE_VERSION) && RL_READLINE_VERSION >= 0x0400 rl_cleanup_after_signal(); #endif fprintf(stderr, "JACK shut down, exiting ...\n"); exit(1); }
/** * Handles the signals to programs. Currently functions only for SIGINTS when * a program is being executed * @param signum The signal number */ void sighandler(int signum){ if(signum == SIGINT){ if(acceptInterrupt) kill(runningPid, SIGINT); } rl_free_line_state(); rl_cleanup_after_signal(); }
void gnu_readline_signal_cleanup() { balance.paren = 0; balance.quote = 0; balance.brace = 0; free(gnu_readline_buf); gnu_readline_buf = NULL; rl_free_line_state(); rl_cleanup_after_signal(); }
GNUReadlineUI::GNUReadlineUI(const std::string & histfile) : UI(), m_histfile(histfile) { rl_set_signals(); rl_cleanup_after_signal(); using_history(); read_history(m_histfile.c_str()); }
void console_exit(void) { #ifdef USE_READLINE rl_callback_handler_remove(); #if RL_VERSION_MAJOR >= 4 rl_cleanup_after_signal(); #endif rl_reset_terminal(NULL); #endif }
void sigtstp_handler(int arg) { rl_cleanup_after_signal(); sigset_t mask; sigemptyset(&mask); sigaddset(&mask, SIGTSTP); sigprocmask(SIG_UNBLOCK, &mask, NULL); signal(SIGTSTP, SIG_DFL); raise(SIGTSTP); signal(SIGTSTP, sigtstp_handler); }
static RETSIGTYPE got_fatal_signal( int sig ) { const char *s; if( caught_fatal_sig ) raise( sig ); caught_fatal_sig = 1; secmem_term(); #ifdef HAVE_LIBREADLINE rl_free_line_state (); rl_cleanup_after_signal (); #endif tty_cleanup_after_signal (); /* Better don't translate these messages. */ write(2, "\n", 1 ); s = log_get_name(); if( s ) write(2, s, strlen(s) ); write(2, ": ", 2 ); #if HAVE_DECL_SYS_SIGLIST && defined(NSIG) s = (sig >= 0 && sig < NSIG) ? sys_siglist[sig] : "?"; write (2, s, strlen(s) ); #else write (2, "signal ", 7 ); if (sig < 0 || sig >=100) write (2, "?", 1); else { if (sig >= 10) write (2, "0123456789"+(sig/10), 1 ); write (2, "0123456789"+(sig%10), 1 ); } #endif write(2, " caught ... exiting\n", 20 ); #ifdef __VMS /* 2006-08-10 SMS. Restore terminal echo, if needed, before exiting. */ vms_set_term_echo (-1); #endif /* def __VMS */ /* Reset action to default action and raise signal again. */ init_one_signal (sig, SIG_DFL, 0); dotlock_remove_lockfiles (0); #ifdef __riscos__ riscos_close_fds (); #endif /* __riscos__ */ raise( sig ); }
static void handle_rlinput(char *rd) { if (rd == NULL) { exit_handler(); #if RL_VERSION_MAJOR >= 4 rl_cleanup_after_signal(); #endif rl_reset_terminal(NULL); #ifdef THREADS pthread_exit(NULL); #else exit(0); #endif } if (*rd != 0) { add_history(rd); } docmd(rd); free(rd); }
void do_halt (int error) { if (!readline_disabled) { rl_free_line_state (); rl_cleanup_after_signal (); } if (write (1, "halt\n", 5) < 0) { // Sad thing } if (unix_socket) { unlink (unix_socket); } if (usfd > 0) { close (usfd); } if (sfd > 0) { close (sfd); } exit (error ? EXIT_FAILURE : EXIT_SUCCESS); }
void termination_signal_handler (int signum) { if (!readline_disabled) { rl_free_line_state (); rl_cleanup_after_signal (); } if (write (1, "SIGNAL received\n", 18) < 0) { // Sad thing } if (unix_socket) { unlink (unix_socket); } if (usfd > 0) { close (usfd); } if (sfd > 0) { close (sfd); } print_backtrace (); exit (EXIT_FAILURE); }
static void rlExit(void *dummy) { if (rlState == rlBusy) rl_cleanup_after_signal(); }
/** * nmc_cleanup_readline: * * Cleanup readline when nmcli is terminated with a signal. * It makes sure the terminal is not garbled. */ void nmc_cleanup_readline (void) { rl_free_line_state (); rl_cleanup_after_signal (); }