RtAttachShutdownHandler
RtAttachShutdownHandler registers a stop/shutdown notification handler function with RTSS. The handler function is called in its own thread when one of the system stop events occurs.
NOTE: This function is only supported in the RTSS environment. It cannot be called from a Windows application linked to RTX64.
Syntax
HANDLE RtAttachShutdownHandler( PSECURITY_ATTRIBUTES pThreadAttributes, ULONG Stacksize, VOID (RTFCNDCL *Routine) (PVOID Context, LONG reason), PVOID Context, ULONG Priority );
Parameters
pThreadAttributes
Ignored.
StackSize
The number of bytes to allocate for the handler thread's stack. See Create Thread
Routine
The handler function to call when RTSS delivers the stop notification.
Context
The argument to the handler routine.
Priority
The priority for the created thread.
Return Value
A valid handle when a stop handler object has been correctly instantiated, a NULL handle if the function fails.
To get extended error information, call GetLastError.
Remarks
The function pointed to by Routine is called when Windows shuts down. The source of the stop notification is presented to this function in the reason argument. The reason argument may have one of the following values according the reason for the notification:
SHTDN_REASON_WINDOWS_SYSTEM_SHUTDOWN |
The system is starting a normal shutdown. Shortly after all shutdown handlers have been executed, Windows will stop. |
SHTDN_REASON_WINDOWS_STOP |
Windows has stopped (i.e., blue screen or stop screen). RTSS will continue to operate with service restrictions. |
SHTDN_REASON_RTX_SYSTEM_SHUTDOWN |
RTX64 Subsystem is going to be stopped (i.e., RTX64 is going to be unloaded). RTSS will continue to operate with service restriction. |
The order in which the shutdown handlers execute is dependent upon the priority specified when the handler object was created. This priority is simply the RTSS thread priority.
Only one shutdown handler object is permitted per RTSS process. A handler function should not call ExitThread, but should simply return when finished. When all registered shutdown handlers have returned, the system completes the shutdown sequence.
A shutdown handler object may be destroyed by calling RtReleaseShutdownHandler.
NOTE: Only those calls that do not interact with the Windows operating system can be made from within the shutdown handler.
RtAttachShutdownHandler behaves differently between Windows and the Real-time Subsystem (RTSS), as explained in the table below:
Windows | RTSS | |
---|---|---|
Application Behavior | The application continues after the notification handler thread completes | The application exits after the notification handler thread completes |
Handled Events | Handles the Subsystem Shutdown event only; does not support any other events supported on the RTSS side | Handles all RTSS-supported events |
Requirements
Minimum Supported Version | RTX64 2013 |
Header | Rtapi.h |
Library | Rtx_Rtss.lib |
See Also: