Signal handling in Windows

LSF uses the UNIX signal mechanism to perform job control. For example, the bkill command in UNIX normally results in the signals SIGINT, SIGTERM, and SIGKILL being sent to the target job. Signal handling code that exists in UNIX applications allows processes to shut down in stages. In the past, the Windows equivalent to the bkill command was TerminateProcess(). It terminates the process immediately and does not allow the process to release shared resources the way bkill does.

LSF provides signal notification through the Windows message queue. LSF includes messages corresponding to common UNIX signals to enable a customized Windows application to process these messages.

For example, the bkill command sends the SIGINT and SIGTERM signals to Windows applications as job control messages. An LSF-aware Windows application can interpret these messages and shut down cleanly.

To write a Windows application that takes advantage of this feature, register the specific signal messages that the application handles. Then modify the message loop to check each message before dispatching it. Take the appropriate action if the message is a job control message.

The following examples show sample code to help you to write your own applications.