unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* graceful shutdown of non-interactive Elisp program
@ 2020-06-13 21:42 Paul Pogonyshev
  2020-06-13 22:59 ` Joost Kremers
  2020-06-14 15:01 ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Pogonyshev @ 2020-06-13 21:42 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1059 bytes --]

Hi,

I'm trying to make a Elisp program that is run in a non-interactive mode,
i.e. essentially as `emacs --batch --load myfile.el'. A normal way to
shutdown terminal programs is with C-c, which is expected to be "graceful"
shutdown, e.g. the program still has a chance to save files etc.

However, with Elisp I'm not sure how to achieve that except for constantly
modifying `kill-emacs-hook', which would be a nightmare from coding
perspective.

Naively I would expect this print "GOING DOWN" when aborted with C-c:

    $ emacs --batch --eval "(unwind-protect (while t) (message \"GOING
DOWN\"))"

For example, Python's handler of SIGINT raises an exception within the
program, which unwinds the stack as usual and, unless caught, cause program
termination after cleaning up as expected (e.g. running all `finally'
clauses and closing all `with' context managers). However, in Elisp, as I
understand, there is no way to have a say in handling SIGINT other than
adding a function to `kill-emacs-hook'.

Is that correct, or am I missing something here?

Paul

[-- Attachment #2: Type: text/html, Size: 1560 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-14 16:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-13 21:42 graceful shutdown of non-interactive Elisp program Paul Pogonyshev
2020-06-13 22:59 ` Joost Kremers
2020-06-14 15:01 ` Eli Zaretskii
2020-06-14 16:47   ` Paul Pogonyshev

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).