This is the mail archive of the
mailing list for the Cygwin project.
Re: System shutdown messages
- From: Ken Brown <kbrown at cornell dot edu>
- To: cygwin at cygwin dot com
- Date: Mon, 9 May 2016 14:08:39 -0400
- Subject: Re: System shutdown messages
- Authentication-results: sourceware.org; auth=none
- References: <d7122da5-24b5-7209-74a9-83d7484872ce at cornell dot edu> <6031de0d-846a-f006-3c1a-d2af7cfb4590 at dronecode dot org dot uk>
On 5/9/2016 1:20 PM, Jon Turney wrote:
On 09/05/2016 14:35, Ken Brown wrote:
A Cygwin emacs user has asked
(http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23483) whether emacs can
auto-save files when he shuts down Windows from the Start Menu. Is
there a way for a Cygwin process to listen for Windows system shutdown
This seems entirely possible using the Win32 API.
For emacs-w32, it's probably straightforward to handle WM_ENDSESSION in
the message loop similarly to WM_CLOSE
(Note that the process will be terminated if you return from processing
a WM_ENDSESSION message)
For emacs-nox and emacs-x11 it's more complex, as you'd have to create
your own hidden window to receive the WM_ENDSESSION, and either select()
on a /dev/windows fd or block in GetMessage() on a separate thread.
(see  for an example of the latter approach as used in the X server)
But I'm not sure that's the best approach, or if wouldn't be more
appropriate to arrange for SIGTERM to be sent to emacs (or whatever) by
mintty or the X server when an WM_ENDSESSION is received...
Thanks, Jon. Yes, the latter approach seems much better. Of course, SHTDI.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple