Subject: Re: NT services and gnu-win32
From: [email-masked]

3 May 1997 13:32:04 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Sender: [email-masked]
X-Mailer: Windows Eudora Light Version 1.5.4 (32)
Original-To: [email-masked]
Original-Sender: [email-masked]

At 04:19 PM 05/02/97 -0400, [email-masked] (Steve Coleman) wrote:
>Hi,
>
>I just downloaded the cygwin suite and ported my first Unix source code to NT 
>yesterday and I was quite impressed with the ease at which I was able to do 
>it. The program (a derivative of the TIS toolkit "smap") works fine from the 
>command line but needs to run as a daemon on the system to be useful.  I then 
>tried to use the NT resource kit (srvany.exe) to load the application as an NT 
>service.  Everything works fine until someone logs out of the system at which 
>time NT (sends messages? WM_ENDSESSION and CTRL_LOGOFF_EVENT) kills it. If the 
>service is loaded when the machine boots the process still dies when the first 
>person logs out.  Even the cygwin nohup.exe does not help.

This is a known problem with srvany, not Cygwin.  From srvany.wri:
"
Programming Considerations:

For WIN32 graphical applications: when the currently logged-in user is
logging-off, all WIN32 top-level windows receive WM_QUERYENDSESSION and
WM_ENDSESSION messages. Some WIN32 applications choose to terminate upon
receipt of such messages. In order for your WIN32 application to survive
logoff, it must not do that: instead, your windows procedure should call the
default windows procedure on these messages.

For WIN32 Console (i.e. character-mode) applications: when the currently
logged-in user is logging-off, all Console applications receive a
CTRL_LOGOFF_EVENT event from the Console. 
If your Console application has registered a Console event handler (via
SetConsoleCtrlHandler), it must ignore CTRL_LOGOFF_EVENT in order  to
survive the logoff.
"
Either try registering a Console event handler or rewrite the code as a
service (not a trivial task).

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".