.. _program_listing_file_src_common_signal_handling.h: Program Listing for File signal_handling.h ========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``src/common/signal_handling.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include #include // SIGNAL HANDLING // The signal handlers (and checkers) here are implemented in line with with the recommendations // for signal handling in the SEI CERT C Coding Standard, specifically // // - SIG30-C: // https://wiki.sei.cmu.edu/confluence/display/c/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers // // - SIG31-C: // https://wiki.sei.cmu.edu/confluence/display/c/SIG31-C.+Do+not+access+shared+objects+in+signal+handlers // // The exact behavior of 'graceful exit' depends on the application; for training, it means 'save model and exit', // for a server (not implemented yet): 'block new requests but serve pending requests and then exit'. // // Graceful exit for training is useful for training on clusters with time limits on jobs. Slurm, for example, can be // set up to send a custom signal at a set time before the end of the time slot, giving Marian time to save its current // state before getting killed. namespace marian { void requestSaveAndExit(int sig); bool saveAndExitRequested(); // (only for SIGNAL No. < 32). void setSignalFlag(int sig); // custom handler (set flag) for sig bool getSignalFlag(int sig); } // End of namespace marian