[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exit hooks not run at logout on w32

From: Lennart Borgman
Subject: Re: Exit hooks not run at logout on w32
Date: Wed, 28 Jun 2006 19:17:15 +0200
User-agent: Thunderbird (Windows/20060516)

Jason Rumney wrote:
Lennart Borgman <address@hidden> writes:

Where is the code that discovers that WM_CLOSE has been sent to the
last frame and that Emacs should be killed?

WM_CLOSE is received in w32fns.c and passed on to lisp in w32term.c,
the same as most other windows messages. But I think you will find
that the system does not send a WM_CLOSE in these circumstances,
because that would trigger the exit hooks if it was the case.
Yes, you are right. There was no WM_CLOSE and indeed also no WM_QUERYENDSESSION. At least not in the case that I have been looking at: starting emacs.exe from cmd.exe. I believe that this might be due to that MS Windows believes that emacs.exe is a console app.

Actually emacs recieve a control event instead, CTRL_LOGOFF_EVENT during my testing. (It could also be CTRL_SHUTDOWN_EVENT and probably CTRL_CLOSE_EVENT.) This event can be catched in ctrl_c_handler in w32console.c. I have tried that and then used PostThreadMessage (dwWindowsThreadId, WM_EMACS_KILL, 0, 0) to be able to call save-buffers-kill-emacs later on.

WM_EMACS_KILL seems ok to use here, it is not used anywhere else as far as I can see. It is passed on and shows up in w32_msg_pump. There I am trying to use my_post_msg to pass it to the lisp thread. However it does not show up in w32_read_socket so I guess I am doing something wrong. My call to my_post_msg looks like this:

static void
w32_msg_pump (deferred_msg * msg_buf)
 MSG msg;
 int result;
 HWND focus_window;
 BOOL bRet;

 msh_mousewheel = RegisterWindowMessage (MSH_MOUSEWHEEL);

 while ( (bRet = GetMessage (&msg, NULL, 0, 0)) != 0)
     if (-1 == bRet) {
       // error, handle?
     } else {
     if (msg.hwnd == NULL)
     switch (msg.message)
           case WM_EMACS_KILL:
               W32Msg wmsg;
               printf("w32_msg_pump: WM_EMACS_KILL\n"); fflush(stdout);
               my_post_msg (&wmsg, 0, msg, 0, 0);

Should it show up in w32_read_socket after this or am I misunderstanding something? In w32_read_socket I do

       case WM_EMACS_KILL:
         printf("w32_read_socket WM_EMACS_KILL\n"); fflush(stdout);

I would appreciate some help here.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]