httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From TOKI...@aol.com
Subject Re: [Patch 1.3.13] The hold console open patch arrives...
Date Tue, 27 Jun 2000 03:47:05 GMT

In a message dated 00-06-26 15:07:14 EDT, William Rowe writes...

> So attached is a patch that should do just this.  Some extra
> exit() codes needed to be cleaned up in the process.  Beat up 
> on it if you like, rewrite it if you like, but unless I hear an
> objection by Wed at noon, I'll commit then.

Patch looks good.

> I mentioned the other thing... never telling users about the
> NT service failure.  I have a quick solve for that too, possibily.
> It's a real hack.  A one message resource file that is nothing
> more than the error message "Error: %1" (sucks one string arg) 
> that will be called for every stderr event.  (Sorry, but the NT 
> event log doesn't take strings, only message codes and a %n style 
> string arg list.  We need a single message to force strings down 
> the throat of ReportEvent().)

This is just FYI but if you are really worried about the 
Apache 'Service' thread being able to notify the user
about something in 'real time' even without a valid
console check out the following piece of kit...

The following is an example of a Service Thread that
can put a regular Windows 'Message Box' on the screen
at any moment, even when there is no user logged on
and even if the Service was created and/or launched
from a console app that 'technically' has no message
queue or window associated with it.

The key is to ALWAYS use '0' as window handle.
GetDesktopWindow() won't work if it's NT and there
is no user signed on AFAIK... it has to be '0' which
has 'special meaning'.

int g_service_is_running=1;
int g_something_god_awful_happened=0;
int g_service_message_box_is_showing=0;

DWORD ServiceExecutionThread( LPDWORD param )
{
 /*+
 This is the main thread of execution for the
 service while it is running.
 +*/

 while( g_service_is_running )
   {
    if ( g_something_god_awful_happened )
      {
       if ( g_service_message_box_is_showing == 0 )
         {
          g_service_message_box_is_showing = 1;
           
          MessageBox(
          0,
          "Something awful happened inside the Service",
          "Service ERROR",
          MB_OK|MB_SET_FOREGROUND|MB_TOPMOST          
          );         

          g_service_message_box_is_showing = 0;
       
         }// End 'if( g_service_message_box_is_showing )' 

      }// End 'if( g_something_god_awful_happened )' 

    // Normal Service code goes here
 
   }// End 'while( g_service_is_running )' 

 return 0; // End the Service thread 

}// End of ServiceExecutionThread()

If you want the MessageBox to show up under NT even when
no user is logged onto the machine you have to use
the MB_SET_FOREGROUND and MB_SET_TOPMOST stuff or the
box might get 'stuck' behind the normal 'Press Ctrl-Alt-Del
to log on' window and user will never see it since that
window itself is using the same 'TOPMOST' flags.

The example uses some 'flags' that prevent the box
from showing more than once if the error condition
hasn't been handled yet. The example waits for a
response but if it used the 'MODAL' flag the service
contines to execute normally but the box stays on
the screen and only appears once because of the
internal 'is_showing' control flag(s).

You can use any of the 'normal' message box flags
at any time from within the Service including the
ones that make it 'SYSTEM MODAL'.

These, are the Message Box flags from
WINUSER.H reprinted for reference...

/*
 * MessageBox() Flags
 */
#define MB_OK                       0x00000000L
#define MB_OKCANCEL                 0x00000001L
#define MB_ABORTRETRYIGNORE         0x00000002L
#define MB_YESNOCANCEL              0x00000003L
#define MB_YESNO                    0x00000004L
#define MB_RETRYCANCEL              0x00000005L
#define MB_ICONHAND                 0x00000010L
#define MB_ICONQUESTION             0x00000020L
#define MB_ICONEXCLAMATION          0x00000030L
#define MB_ICONASTERISK             0x00000040L
#if(WINVER >= 0x0400)
#define MB_USERICON                 0x00000080L
#define MB_ICONWARNING              MB_ICONEXCLAMATION
#define MB_ICONERROR                MB_ICONHAND
#endif /* WINVER >= 0x0400 */
#define MB_ICONINFORMATION          MB_ICONASTERISK
#define MB_ICONSTOP                 MB_ICONHAND
#define MB_DEFBUTTON1               0x00000000L
#define MB_DEFBUTTON2               0x00000100L
#define MB_DEFBUTTON3               0x00000200L
#if(WINVER >= 0x0400)
#define MB_DEFBUTTON4               0x00000300L
#endif /* WINVER >= 0x0400 */
#define MB_APPLMODAL                0x00000000L
#define MB_SYSTEMMODAL              0x00001000L
#define MB_TASKMODAL                0x00002000L
#if(WINVER >= 0x0400)
#define MB_HELP                     0x00004000L // Help Button
#endif /* WINVER >= 0x0400 */
#define MB_NOFOCUS                  0x00008000L
#define MB_SETFOREGROUND            0x00010000L
#define MB_DEFAULT_DESKTOP_ONLY     0x00020000L
#if(WINVER >= 0x0400)
#define MB_TOPMOST                  0x00040000L
#define MB_RIGHT                    0x00080000L
#define MB_RTLREADING               0x00100000L
#endif

Yours...

Kevin Kiley
CTO, Remote Communications, Inc.
http://www.RemoteCommunications.com
http://www.rctp.com - Online Internet Content Compression Server

Mime
View raw message