X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=H+LyrXnldwjAkn17 LwAQfOC4d7ZxpIQ/3pGnIKB8ZqicIf86xshajgFx/yz2kwt14pgi1vC/y9pHtwkI JmdvfWq6XUjwhx/TbRCkeTb9ZSYuSA3ABnTdNnjybvSqKNrgtkHr7CAcmli+WQJI GgWx0PDjfvs9A/i64xDXc6+0lgc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=PhTwT54zi07TZVqmFeMhnG wBohM=; b=Q6NKVwsirkuotNVyMNKZlIguon0mx31434SVCN0uDt7hj6MGJ490Bw yp7fk3q+syfYQ2A4oKRJnfxmKnQPenh8C/7j8uK4YfZK77GpAhVrGzDg6mXQvat/ qKPK/URdNZuOSXPSZJkMZvMjh4eoeCp5hscL/XrXMFtJsSgQlk0eU= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:ip*192.168.1.5, Hx-spam-relays-external:!192.168.1.5!, H*RU:!192.168.1.5!, H*f:sk:6031de0 X-HELO: limerock03.mail.cornell.edu X-CornellRouted: This message has been Routed already. Subject: Re: System shutdown messages To: cygwin AT cygwin DOT com References: <6031de0d-846a-f006-3c1a-d2af7cfb4590 AT dronecode DOT org DOT uk> From: Ken Brown Message-ID: Date: Mon, 9 May 2016 14:08:39 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <6031de0d-846a-f006-3c1a-d2af7cfb4590@dronecode.org.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Cornell-Gauge: Gauge=XXXXX X-IsSubscribed: yes 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