| 118 | /* End my_sys */ |
| 119 | |
| 120 | void my_end(int infoflag) |
| 121 | { |
| 122 | /* |
| 123 | this code is suboptimal to workaround a bug in |
| 124 | Sun CC: Sun C++ 5.6 2004/06/02 for x86, and should not be |
| 125 | optimized until this compiler is not in use anymore |
| 126 | */ |
| 127 | FILE *info_file= DBUG_FILE; |
| 128 | my_bool print_info= (info_file != stderr); |
| 129 | |
| 130 | if (!my_init_done) |
| 131 | return; |
| 132 | |
| 133 | /* |
| 134 | We do not use DBUG_ENTER here, as after cleanup DBUG is no longer |
| 135 | operational, so we cannot use DBUG_RETURN. |
| 136 | */ |
| 137 | DBUG_PRINT("info",("Shutting down: infoflag: %d print_info: %d", |
| 138 | infoflag, print_info)); |
| 139 | if (!info_file) |
| 140 | { |
| 141 | info_file= stderr; |
| 142 | print_info= 0; |
| 143 | } |
| 144 | |
| 145 | if ((infoflag & MY_CHECK_ERROR) || print_info) |
| 146 | |
| 147 | { /* Test if some file is left open */ |
| 148 | if (my_file_opened | my_stream_opened) |
| 149 | { |
| 150 | char ebuff[512]; |
| 151 | my_snprintf(ebuff, sizeof(ebuff), EE(EE_OPEN_WARNING), |
| 152 | my_file_opened, my_stream_opened); |
| 153 | my_message_stderr(EE_OPEN_WARNING, ebuff, ME_BELL); |
| 154 | DBUG_PRINT("error", ("%s", ebuff)); |
| 155 | my_print_open_files(); |
| 156 | } |
| 157 | } |
| 158 | free_charsets(); |
| 159 | my_error_unregister_all(); |
| 160 | my_once_free(); |
| 161 | |
| 162 | if ((infoflag & MY_GIVE_INFO) || print_info) |
| 163 | { |
| 164 | #ifdef HAVE_GETRUSAGE |
| 165 | struct rusage rus; |
| 166 | #ifdef HAVE_purify |
| 167 | /* Purify assumes that rus is uninitialized after getrusage call */ |
| 168 | memset(&rus, 0, sizeof(rus)); |
| 169 | #endif |
| 170 | if (!getrusage(RUSAGE_SELF, &rus)) |
| 171 | fprintf(info_file,"\n\ |
| 172 | User time %.2f, System time %.2f\n\ |
| 173 | Maximum resident set size %ld, Integral resident set size %ld\n\ |
| 174 | Non-physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\n\ |
| 175 | Blocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\n\ |
| 176 | Voluntary context switches %ld, Involuntary context switches %ld\n", |
| 177 | (rus.ru_utime.tv_sec * SCALE_SEC + |