Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-Id: <199912151945.TAA28429@cav.logica.co.uk> To: cygwin AT sourceware DOT cygnus DOT com Subject: re: Win32 shutdown From: fieldhouse AT logica DOT com (Dirk Fieldhouse) Organization: Logica plc (for whom I do not speak) Date: Wed, 15 Dec 1999 19:44:57 +0000 X-Mailer: WinVN 0.99.10 beta4 [mds] (x86 32bit) MIME-Version: 1.0 Content-Type: Text/Plain; charset=US-ASCII On Wed, 15 Dec 1999 08:57:40 -0500, Jeremy Gunter wrote: > I have just started using cygwin. Very impressed so far. I am almost done > porting a small Linux application I had previously written, and I would > like it to run as a service. My question is how do I get the program to > exit when windows shuts down without windows complaining that it can't > shutdown the program automatically. I don't want the user to have to > explicitly shut down the application before exiting. Normally you'd have a Windows application with a hidden window and a message loop, and a window procedure in which you'd handle WM_QUERYENDSESSION by returning true to indicate that you're prepared to shut down (then you get WM_CLOSE as normal). Search on WM_QUERYENDSESSION at M$. If you don't have this you can create a thread that does nothing else. You'll have a signal handler of some sort in your ported thread that recognises when to shut down, and you'll send that signal from the window thread. For a die-hard console-only, not-calling-user32.dll-at-all app, you can investigate the .pif attribute that allows a command window to be closed by Windows. I don't know how this works on NT. If your app should be persistent across logouts, you may also like to read about services (we may prefer daemons in this group) at http://msdn.microsoft.com/library/psdk/winbase/services_2fg3.htm and http://msdn.microsoft.com/library/psdk/win95/95scm_5vl9.htm -- Dirk Fieldhouse Logica UK Limited fieldhouse AT logica DOT com 75 Hampstead Road c=gb;a=attmail;p=logica; London NW1 2PL o=LOGICA;ou1=UK;s=fieldhouse UK +44 (20) 7637 9111 -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com