Function: suspend-emacs

suspend-emacs is an interactive function defined in keyboard.c.

Signature

(suspend-emacs &optional STUFFSTRING)

Documentation

Stop Emacs and return to superior process. You can resume later.

If cannot-suspend is non-nil, or if the system doesn't support job control, run a subshell instead.

If optional arg STUFFSTRING is non-nil, its characters are stuffed to be read as terminal input by Emacs's parent, after suspension.

Before suspending, run the normal hook suspend-hook. After resumption run the normal hook suspend-resume-hook.

Some operating systems cannot stop the Emacs process and resume it later. On such systems, Emacs starts a subshell instead of suspending.

Probably introduced at or before Emacs version 1.1.

Key Bindings

Source Code

// Defined in /usr/src/emacs/src/keyboard.c
{
  ptrdiff_t count = SPECPDL_INDEX ();
  int old_height, old_width;
  int width, height;

  if (tty_list && tty_list->next)
    error ("There are other tty frames open; close them before suspending Emacs");

  if (!NILP (stuffstring))
    CHECK_STRING (stuffstring);

  run_hook (intern ("suspend-hook"));

  get_tty_size (fileno (CURTTY ()->input), &old_width, &old_height);
  reset_all_sys_modes ();
  /* sys_suspend can get an error if it tries to fork a subshell
     and the system resources aren't available for that.  */
  record_unwind_protect_void (init_all_sys_modes);
  stuff_buffered_input (stuffstring);
  if (cannot_suspend)
    sys_subshell ();
  else
    sys_suspend ();
  unbind_to (count, Qnil);

  /* Check if terminal/window size has changed.
     Note that this is not useful when we are running directly
     with a window system; but suspend should be disabled in that case.  */
  get_tty_size (fileno (CURTTY ()->input), &width, &height);
  if (width != old_width || height != old_height)
    change_frame_size (SELECTED_FRAME (), width, height, false, false, false);

  run_hook (intern ("suspend-resume-hook"));

  return Qnil;
}