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 public: 00030 // The enumeration of the exit codes that Houdini producs can use. 00031 // (see notes in http://tldp.org/LDP/abs/html/exitcodes.html) 00032 // NOTE: the numeric values for the specific exit reasons should not change: 00033 // some customers explicitly test the numeric value of the exit code 00034 // and take a specific action based on it. E.g., they may test the 00035 // exit code for the license failure on a render farm for 00036 // re-submission, but if we change the exit code for license failure 00037 // their scripts will need to be updated to account for that. 00038 // NOTE: don't use exit code value of 259. On Windows, the exit code 259 00039 // means STILL_ACTIVE, and should not be used as an exit error code; 00040 // otherwise the return value of GetExitCodeProcess() calls may be 00041 // misinterpreted. 00042 enum UT_ExitCode 00043 { 00044 // no error 00045 EXIT_OK = 0, 00046 00047 // catch-all error code 00048 EXIT_GENERIC_ERROR = 1, 00049 00050 // misuse of shell builtins (according to Bash documentation) 00051 EXIT_BUILTIN_ERROR = 2, 00052 00053 // failure to check out or verify an appropriate product license 00054 EXIT_LICENSE_ERROR = 3, 00055 00056 // socket communication failure 00057 EXIT_SOCKET_ERROR = 4, 00058 00059 // failed to parse the UI definition file 00060 EXIT_PARSE_UI_ERROR = 5 00061 }; 00062 00063 // Calls exit(), which implicitly leads to our callbacks being called. 00064 static void exit( UT_ExitCode exit_code = EXIT_OK ); 00065 00066 // Just like exit(), except sets the exit code to the properly offset 00067 // signal number according to the convention: 128 + signal_number. 00068 static void exitWithSignalNumber( int signal_number ); 00069 00070 // An exit method that takes any exit code (as integer). Should be used 00071 // sparignly and only if necessary. We want the exit codes to be 00072 // consistent, stable and well-known to the customers (we can document 00073 // based on the above enum), so use exit() with UT_ExitCode, if possible. 00074 static void exitWithSpecificCode( int exit_code ); 00075 00076 // Calls our callbacks directly, without calling exit(). This should 00077 // only be used by our core dump handler. 00078 static void runExitCallbacks(); 00079 00080 // Returns 1 if the function was added, the function can only be added one 00081 // time. Returns 0 if this is a duplicate. 00082 static int addExitCallback(void (*exitcallback)(void *data), 00083 void *data = 0); 00084 // Returns 1 if the function was removed. Returns 0 if the function was 00085 // never added. 00086 static int removeExitCallback(void (*exitcallback)(void *data), 00087 void *data = 0); 00088 00089 // Remove all the exit callbacks. 00090 static void removeAllExitCallbacks(); 00091 }; 00092 00093 #endif
1.5.9