mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
Make error handling a little more robust.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8508 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f16a17fa42
commit
eed73def23
@ -1,3 +1,8 @@
|
|||||||
|
2004-03-22 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
* lyx_main.C (error_handler, init): remove handler for SIGPIPE.
|
||||||
|
Ensure that error_handler is processed once only and that all data
|
||||||
|
is saved before attempting to output any warning messages.
|
||||||
|
|
||||||
2004-03-21 Alfredo Braunstein <abraunst@lyx.org>
|
2004-03-21 Alfredo Braunstein <abraunst@lyx.org>
|
||||||
|
|
||||||
@ -12,11 +17,11 @@
|
|||||||
|
|
||||||
* paragraph.[Ch]: fix completely broken operator=()
|
* paragraph.[Ch]: fix completely broken operator=()
|
||||||
|
|
||||||
|
|
||||||
2004-03-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
2004-03-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||||
|
|
||||||
* LColor.C (getFromLyXName): make sure that the color name is used
|
* LColor.C (getFromLyXName): make sure that the color name is used
|
||||||
as lowercase.
|
as lowercase.
|
||||||
|
|
||||||
2004-03-17 Angus Leeming <leeming@lyx.org>
|
2004-03-17 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
* lfuns.h:
|
* lfuns.h:
|
||||||
|
@ -258,34 +258,45 @@ extern "C" {
|
|||||||
|
|
||||||
static void error_handler(int err_sig)
|
static void error_handler(int err_sig)
|
||||||
{
|
{
|
||||||
|
// Throw away any signals other than the first one received.
|
||||||
|
static sig_atomic_t handling_error = false;
|
||||||
|
if (handling_error)
|
||||||
|
return;
|
||||||
|
handling_error = true;
|
||||||
|
|
||||||
|
// We have received a signal indicating a fatal error, so
|
||||||
|
// try and save the data ASAP.
|
||||||
|
LyX::cref().emergencyCleanup();
|
||||||
|
|
||||||
|
// These lyxerr calls may or may not work:
|
||||||
|
|
||||||
|
// Signals are asynchronous, so the main program may be in a very
|
||||||
|
// fragile state when a signal is processed and thus while a signal
|
||||||
|
// handler function executes.
|
||||||
|
// In general, therefore, we should avoid performing any
|
||||||
|
// I/O operations or calling most library and system functions from
|
||||||
|
// signal handlers.
|
||||||
|
|
||||||
|
// This shouldn't matter here, however, as we've already invoked
|
||||||
|
// emergencyCleanup.
|
||||||
switch (err_sig) {
|
switch (err_sig) {
|
||||||
case SIGHUP:
|
case SIGHUP:
|
||||||
lyxerr << "\nlyx: SIGHUP signal caught" << endl;
|
lyxerr << "\nlyx: SIGHUP signal caught\nBye." << endl;
|
||||||
break;
|
|
||||||
case SIGINT:
|
|
||||||
// no comments
|
|
||||||
break;
|
break;
|
||||||
case SIGFPE:
|
case SIGFPE:
|
||||||
lyxerr << "\nlyx: SIGFPE signal caught" << endl;
|
lyxerr << "\nlyx: SIGFPE signal caught\nBye." << endl;
|
||||||
break;
|
break;
|
||||||
case SIGSEGV:
|
case SIGSEGV:
|
||||||
lyxerr << "\nlyx: SIGSEGV signal caught" << endl;
|
lyxerr << "\nlyx: SIGSEGV signal caught\n"
|
||||||
lyxerr <<
|
"Sorry, you have found a bug in LyX. "
|
||||||
"Sorry, you have found a bug in LyX. "
|
"Please read the bug-reporting instructions "
|
||||||
"Please read the bug-reporting instructions "
|
"in Help->Introduction and send us a bug report, "
|
||||||
"in Help->Introduction and send us a bug report, "
|
"if necessary. Thanks !\nBye." << endl;
|
||||||
"if necessary. Thanks !" << endl;
|
|
||||||
break;
|
break;
|
||||||
|
case SIGINT:
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
// no comments
|
// no comments
|
||||||
break;
|
break;
|
||||||
case SIGPIPE:
|
|
||||||
// This will be received if lyx tries to write to a socket
|
|
||||||
// whose reading end was closed. It can safely be ignored,
|
|
||||||
// as in this case the ::write() system call will return -1
|
|
||||||
// and errno will be set to EPIPE
|
|
||||||
return;
|
|
||||||
//break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deinstall the signal handlers
|
// Deinstall the signal handlers
|
||||||
@ -294,13 +305,9 @@ static void error_handler(int err_sig)
|
|||||||
signal(SIGFPE, SIG_DFL);
|
signal(SIGFPE, SIG_DFL);
|
||||||
signal(SIGSEGV, SIG_DFL);
|
signal(SIGSEGV, SIG_DFL);
|
||||||
signal(SIGTERM, SIG_DFL);
|
signal(SIGTERM, SIG_DFL);
|
||||||
signal(SIGPIPE, SIG_DFL);
|
|
||||||
|
|
||||||
LyX::cref().emergencyCleanup();
|
if (err_sig == SIGSEGV ||
|
||||||
|
(err_sig != SIGHUP && !GetEnv("LYXDEBUG").empty()))
|
||||||
lyxerr << "Bye." << endl;
|
|
||||||
if (err_sig!= SIGHUP &&
|
|
||||||
(!GetEnv("LYXDEBUG").empty() || err_sig == SIGSEGV))
|
|
||||||
lyx::support::abort();
|
lyx::support::abort();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -323,7 +330,7 @@ void LyX::init(bool gui)
|
|||||||
signal(SIGSEGV, error_handler);
|
signal(SIGSEGV, error_handler);
|
||||||
signal(SIGINT, error_handler);
|
signal(SIGINT, error_handler);
|
||||||
signal(SIGTERM, error_handler);
|
signal(SIGTERM, error_handler);
|
||||||
signal(SIGPIPE, error_handler);
|
// SIGPIPE can be safely ignored.
|
||||||
|
|
||||||
bool const explicit_userdir = setLyxPaths();
|
bool const explicit_userdir = setLyxPaths();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user