restore CatchSignals to fix API compatibility

This commit is contained in:
Zdenko Podobný 2019-06-16 21:08:13 +02:00
parent c5105c5325
commit 78ced35a8b
2 changed files with 25 additions and 0 deletions

View File

@ -253,6 +253,25 @@ size_t TessBaseAPI::getOpenCLDevice(void **data) {
return 0;
}
/**
* Writes the thresholded image to stderr as a PBM file on receipt of a
* SIGSEGV, SIGFPE, or SIGBUS signal. (Linux/Unix only).
*/
void TessBaseAPI::CatchSignals() {
#ifdef __linux__
struct sigaction action;
memset(&action, 0, sizeof(action));
action.sa_handler = &signal_exit;
action.sa_flags = SA_RESETHAND;
sigaction(SIGSEGV, &action, nullptr);
sigaction(SIGFPE, &action, nullptr);
sigaction(SIGBUS, &action, nullptr);
#else
// Warn API users that an implementation is needed.
tprintf("CatchSignals has no non-linux implementation!\n");
#endif
}
/**
* Set the name of the input file. Needed only for training and
* loading a UNLV zone file.

View File

@ -107,6 +107,12 @@ class TESS_API TessBaseAPI {
*/
static size_t getOpenCLDevice(void **device);
/**
* Writes the thresholded image to stderr as a PBM file on receipt of a
* SIGSEGV, SIGFPE, or SIGBUS signal. (Linux/Unix only).
*/
static void CatchSignals();
/**
* Set the name of the input file. Needed for training and
* reading a UNLV zone file, and for searchable PDF output.