00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Mark Elendt 00008 * Side Effects Software Inc 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: UT_Exit.h ( UT Library, C++) 00015 * 00016 * COMMENTS: General exit mechanism... This allows a list of callback 00017 * functions to be added when exit is being called 00018 * The callbacks are called in the order that they were added. 00019 * The callback function will only be added once (even if the data 00020 * is different). 00021 */ 00022 00023 #ifndef __UT_Exit__ 00024 #define __UT_Exit__ 00025 00026 #include "UT_API.h" 00027 00028 class UT_API UT_Exit 00029 { 00030 public: 00031 /// The enumeration of the exit codes that Houdini producs can use. 00032 /// (see notes in http://tldp.org/LDP/abs/html/exitcodes.html) 00033 /// @note The numeric values for the specific exit reasons should not 00034 /// change: some customers explicitly test the numeric value of the 00035 /// exit code and take a specific action based on it. E.g., they may 00036 /// test the exit code for the license failure on a render farm for 00037 /// re-submission, but if we change the exit code for license failure 00038 /// their scripts will need to be updated to account for that. 00039 /// 00040 /// @note Don't use exit code value of 259. On Windows, the exit code 259 00041 /// means STILL_ACTIVE, and should not be used as an exit error code; 00042 /// otherwise the return value of GetExitCodeProcess() calls may be 00043 /// misinterpreted. 00044 enum UT_ExitCode 00045 { 00046 /// no error 00047 EXIT_OK = 0, 00048 00049 /// catch-all error code 00050 EXIT_GENERIC_ERROR = 1, 00051 00052 /// misuse of shell builtins (according to Bash documentation) 00053 EXIT_BUILTIN_ERROR = 2, 00054 00055 /// failure to check out or verify an appropriate product license 00056 EXIT_LICENSE_ERROR = 3, 00057 00058 /// socket communication failure 00059 EXIT_SOCKET_ERROR = 4, 00060 00061 /// failed to parse the UI definition file 00062 EXIT_PARSE_UI_ERROR = 5 00063 }; 00064 00065 /// Calls exit(), which implicitly leads to our callbacks being called. 00066 static void exit( UT_ExitCode exit_code = EXIT_OK ); 00067 00068 /// Just like exit(), except sets the exit code to the properly offset 00069 /// signal number according to the convention: 128 + signal_number. 00070 static void exitWithSignalNumber( int signal_number ); 00071 00072 /// An exit method that takes any exit code (as integer). Should be used 00073 /// sparingly and only if necessary. We want the exit codes to be 00074 /// consistent, stable and well-known to the customers (we can document 00075 /// based on the above enum), so use exit() with UT_ExitCode, if possible. 00076 static void exitWithSpecificCode( int exit_code ); 00077 00078 /// Calls our callbacks directly, without calling exit(). This should 00079 /// only be used by our core dump handler. 00080 static void runExitCallbacks(); 00081 00082 /// Returns 1 if the function was added, the function can only be added one 00083 /// time. Returns 0 if this is a duplicate. 00084 /// 00085 /// @warning Destructors of global variables are called BEFORE the callback 00086 /// is invoked on Windows! 00087 static int addExitCallback(void (*exitcallback)(void *data), 00088 void *data = 0); 00089 /// Returns 1 if the function was removed. Returns 0 if the function was 00090 /// never added. 00091 static int removeExitCallback(void (*exitcallback)(void *data), 00092 void *data = 0); 00093 00094 /// Remove all the exit callbacks. 00095 static void removeAllExitCallbacks(); 00096 }; 00097 00098 #endif
1.5.9