* Writes the thresholded image to stderr as a PBM file on receipt of a * SIGSEGV, SIGFPE, or SIGBUS signal. (Linux/Unix only). */
| 178 | * SIGSEGV, SIGFPE, or SIGBUS signal. (Linux/Unix only). |
| 179 | */ |
| 180 | void TessBaseAPI::CatchSignals() { |
| 181 | #ifdef __linux__ |
| 182 | struct sigaction action; |
| 183 | memset(&action, 0, sizeof(action)); |
| 184 | action.sa_handler = &signal_exit; |
| 185 | action.sa_flags = SA_RESETHAND; |
| 186 | sigaction(SIGSEGV, &action, NULL); |
| 187 | sigaction(SIGFPE, &action, NULL); |
| 188 | sigaction(SIGBUS, &action, NULL); |
| 189 | #else |
| 190 | // Warn API users that an implementation is needed. |
| 191 | tprintf("CatchSignals has no non-linux implementation!\n"); |
| 192 | #endif |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Set the name of the input file. Needed only for training and |