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:references:cc:to:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=wPWiVYbe/YX/fLDh te4bc6rRFYEMPTjS7K6fiJMWnGUaE4jZhq8s3WAkz9V2UixQWK03DJ/xn5ONv/2D t9y5GdBvt+qoOES08CvrGb+rOgulU8KBKm0KChImj3yIxJQ0L41R21U/lDS7ftIv iUZxXcO+rd7fNxsA+K3JTiJYFuU= 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:references:cc:to:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=4hs+rEMgAd5VCQodA+iNPg cJ5mo=; b=SR+YDfFwr8kts9AD+yaxI3hiEEfEc499z5ayB0lcBvZfjyAOXE07OL /H6gXzGJD2wTKDn/ZxqJmN52SxspFPlgFk3Ii3QazVVm3aWCoA+l5eglls3F0+5H TC9nq84RYmGrwYY7s5L9/Hx5/z+lVHvDorhdvtN7JG3WxJglf4SYM= 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.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=Ken, H*MI:sk:d7122da, H*f:sk:d7122da, H*i:sk:d7122da X-HELO: out5-smtp.messagingengine.com Subject: Re: System shutdown messages References: Cc: Ken Brown To: cygwin AT cygwin DOT com From: Jon Turney Message-ID: <6031de0d-846a-f006-3c1a-d2af7cfb4590@dronecode.org.uk> Date: Mon, 9 May 2016 18:20:32 +0100 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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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