| 1098 | volatile BOOLEAN m2_end_called = FALSE; |
| 1099 | |
| 1100 | void m2_end(int i) |
| 1101 | { |
| 1102 | if (!m2_end_called) |
| 1103 | { |
| 1104 | EXTERN_VAR FILE* File_Profiling; |
| 1105 | EXTERN_VAR FILE* File_Log; |
| 1106 | EXTERN_VAR BOOLEAN File_Log_written; |
| 1107 | if (File_Profiling!=NULL) { fclose(File_Profiling); File_Profiling=NULL; } |
| 1108 | if (File_Log!=NULL) |
| 1109 | { |
| 1110 | fclose(File_Log); |
| 1111 | File_Log=NULL; |
| 1112 | if (File_Log_written==FALSE) // remove empty logs |
| 1113 | { |
| 1114 | int pid=getpid(); |
| 1115 | char buf[20]; |
| 1116 | snprintf(buf,20,"/tmp/sing_log.%d",pid); |
| 1117 | remove(buf); |
| 1118 | } |
| 1119 | } |
| 1120 | m2_end_called = TRUE; |
| 1121 | #ifdef HAVE_SIMPLEIPC |
| 1122 | for (int j = SIPC_MAX_SEMAPHORES-1; j >= 0; j--) |
| 1123 | { |
| 1124 | if (semaphore[j] != NULL) |
| 1125 | { |
| 1126 | while (sem_acquired[j] > 0) |
| 1127 | { |
| 1128 | #if PORTABLE_SEMAPHORES |
| 1129 | sem_post(semaphore[j]->sig); |
| 1130 | #else |
| 1131 | sem_post(semaphore[j]); |
| 1132 | #endif |
| 1133 | sem_acquired[j]--; |
| 1134 | } |
| 1135 | } |
| 1136 | } |
| 1137 | #endif // HAVE_SIMPLEIPC |
| 1138 | monitor(NULL,0); |
| 1139 | #ifdef PAGE_TEST |
| 1140 | mmEndStat(); |
| 1141 | #endif |
| 1142 | fe_reset_input_mode(); |
| 1143 | if (ssiToBeClosed_inactive) |
| 1144 | { |
| 1145 | link_list hh=ssiToBeClosed; |
| 1146 | while(hh!=NULL) |
| 1147 | { |
| 1148 | //Print("close %s\n",hh->l->name); |
| 1149 | slPrepClose(hh->l); |
| 1150 | hh=(link_list)hh->next; |
| 1151 | } |
| 1152 | ssiToBeClosed_inactive=FALSE; |
| 1153 | |
| 1154 | idhdl h = currPack->idroot; |
| 1155 | while(h != NULL) |
| 1156 | { |
| 1157 | if(IDTYP(h) == LINK_CMD) |