* System shutdown messages
@ 2016-05-09 13:36 Ken Brown
2016-05-09 17:20 ` Jon Turney
0 siblings, 1 reply; 4+ messages in thread
From: Ken Brown @ 2016-05-09 13:36 UTC (permalink / raw)
To: cygwin
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
messages?
Ken
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: System shutdown messages
2016-05-09 13:36 System shutdown messages Ken Brown
@ 2016-05-09 17:20 ` Jon Turney
2016-05-09 18:08 ` Ken Brown
2016-05-12 20:27 ` Ken Brown
0 siblings, 2 replies; 4+ messages in thread
From: Jon Turney @ 2016-05-09 17:20 UTC (permalink / raw)
To: cygwin; +Cc: Ken Brown
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
> messages?
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 [1] 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...
[1] https://cgit.freedesktop.org/xorg/xserver/tree/hw/xwin/winmsgwindow.c
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: System shutdown messages
2016-05-09 17:20 ` Jon Turney
@ 2016-05-09 18:08 ` Ken Brown
2016-05-12 20:27 ` Ken Brown
1 sibling, 0 replies; 4+ messages in thread
From: Ken Brown @ 2016-05-09 18:08 UTC (permalink / raw)
To: cygwin
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
>> messages?
>
> 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 [1] 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.
Ken
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: System shutdown messages
2016-05-09 17:20 ` Jon Turney
2016-05-09 18:08 ` Ken Brown
@ 2016-05-12 20:27 ` Ken Brown
1 sibling, 0 replies; 4+ messages in thread
From: Ken Brown @ 2016-05-12 20:27 UTC (permalink / raw)
To: cygwin
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
>> messages?
>
> 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
This was indeed straightforward, so I went ahead and did it. But I
didn't try to do anything for emacs-X11 and emacs-nox because it's more
complicated, and...
> 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...
... I hope Someone will do this.
Ken
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-05-12 20:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-09 13:36 System shutdown messages Ken Brown
2016-05-09 17:20 ` Jon Turney
2016-05-09 18:08 ` Ken Brown
2016-05-12 20:27 ` Ken Brown
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).