struct console * decode_console (Lisp_Object console) { if (NILP (console)) console = Fselected_console (); /* quietly accept devices and frames for the console arg */ if (DEVICEP (console) || FRAMEP (console)) console = DEVICE_CONSOLE (decode_device (console)); CHECK_LIVE_CONSOLE (console); return XCONSOLE (console); }
struct console * tty_find_console_from_fd (int fd) { Lisp_Object concons; CONSOLE_LOOP (concons) { struct console *c; c = XCONSOLE (XCAR (concons)); if (CONSOLE_TTY_P (c) && CONSOLE_TTY_DATA (c)->infd == fd) return c; } return 0; }
static void print_console (Lisp_Object obj, Lisp_Object printcharfun, int UNUSED (escapeflag)) { struct console *con = XCONSOLE (obj); if (print_readably) printing_unreadable_lisp_object (obj, XSTRING_DATA (con->name)); write_fmt_string (printcharfun, "#<%s-console", !CONSOLE_LIVE_P (con) ? "dead" : CONSOLE_TYPE_NAME (con)); if (CONSOLE_LIVE_P (con) && !NILP (CONSOLE_CONNECTION (con))) write_fmt_string_lisp (printcharfun, " on %S", 1, CONSOLE_CONNECTION (con)); write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj)); }
static Lisp_Object mark_console (Lisp_Object obj) { struct console *con = XCONSOLE (obj); #define MARKED_SLOT(x) mark_object (con->x); #include "conslots.h" /* Can be zero for Vconsole_defaults, Vconsole_local_symbols */ if (con->conmeths) { mark_object (con->conmeths->symbol); MAYBE_CONMETH (con, mark_console, (con)); } return Qnil; }
static struct console * allocate_console (Lisp_Object type) { Lisp_Object console = ALLOC_NORMAL_LISP_OBJECT (console); struct console *con = XCONSOLE (console); struct gcpro gcpro1; copy_lisp_object (console, Vconsole_defaults); GCPRO1 (console); con->conmeths = decode_console_type (type, ERROR_ME); con->contype = get_console_variant (type); con->command_builder = allocate_command_builder (console, 1); con->function_key_map = Fmake_sparse_keymap (Qnil); Fset_keymap_parents (con->function_key_map, Vfunction_key_map_parent); set_quit_events (con, make_char (7)); /* C-g */ UNGCPRO; return con; }
static SIGTYPE interrupt_signal (int sig) { /* This function can call lisp */ /* #### we should NOT be calling lisp from a signal handler, boys and girls */ /* Must preserve main program's value of errno. */ int old_errno = errno; EMACS_REESTABLISH_SIGNAL (sig, interrupt_signal); /* with the macroized error-checking stuff, the garbage below may mess things up because XCONSOLE() and such can use and change global vars. */ #if ! (defined (ERROR_CHECK_TYPECHECK) && defined (MACROIZE_ERROR_CHECKING)) if (sigint_happened && CONSOLEP (Vcontrolling_terminal) && CONSOLE_LIVE_P (XCONSOLE (Vcontrolling_terminal)) && !emacs_is_blocking) { char c; fflush (stdout); reset_initial_console (); EMACS_UNBLOCK_SIGNAL (sig); #ifdef SIGTSTP /* Support possible in later USG versions */ /* * On systems which can suspend the current process and return to the original * shell, this command causes the user to end up back at the shell. * The "Auto-save" and "Abort" questions are not asked until * the user elects to return to emacs, at which point he can save the current * job and either dump core or continue. */ sys_suspend (); #else /* Perhaps should really fork an inferior shell? But that would not provide any way to get back to the original shell, ever. */ stdout_out ("No support for stopping a process on this operating system;\n"); stdout_out ("you can continue or abort.\n"); #endif /* not SIGTSTP */ stdout_out ("Auto-save? (y or n) "); if (((c = getc (stdin)) & ~040) == 'Y') Fdo_auto_save (Qnil, Qnil); while (c != '\n') c = getc (stdin); stdout_out ("Abort (and dump core)? (y or n) "); if (((c = getc (stdin)) & ~040) == 'Y') ABORT (); while (c != '\n') c = getc (stdin); stdout_out ("Continuing...\n"); reinit_initial_console (); MARK_FRAME_CHANGED (XFRAME (DEVICE_SELECTED_FRAME (XDEVICE (CONSOLE_SELECTED_DEVICE (XCONSOLE (Vcontrolling_terminal)))))); } else #endif /* ! (defined (ERROR_CHECKING) && defined (MACROIZE_ERROR_CHECKING)) */ { /* Else request quit when it's safe */ Vquit_flag = Qt; sigint_happened = 1; #ifdef HAVE_UNIXOID_EVENT_LOOP signal_fake_event (); #endif } errno = old_errno; SIGRETURN; }