+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>
* paragraph.[Ch]: fix completely broken operator=()
-
2004-03-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* LColor.C (getFromLyXName): make sure that the color name is used
as lowercase.
+
2004-03-17 Angus Leeming <leeming@lyx.org>
* lfuns.h:
2004-03-11 André Pönitz <poenitz@gmx.net>
- * buffer.[Ch]: use InsetText instead of LyXText as container for
+ * buffer.[Ch]: use InsetText instead of LyXText as container for
the main lyx text.
* dociterator.[Ch]: drop the BufferView * member which is not needed
* text.C:
* text2.C:
* rowpainter.C:
- * BufferView_pimpl.C: rename textwidth -> maxwidth,
+ * BufferView_pimpl.C: rename textwidth -> maxwidth,
prepareToPrint -> computeRowMetrics and remove textWidth accessor.
2004-03-01 Alfredo Braunstein <abraunst@lyx.org>
2004-03-01 Alfredo Braunstein <abraunst@lyx.org>
- * FontIterator.[Ch]: move FontIterator from lyxtext.h/text.C to here
+ * FontIterator.[Ch]: move FontIterator from lyxtext.h/text.C to here
2004-03-01 Alfredo Braunstein <abraunst@lyx.org>
- * lyxtext.h: add FontIterator class
+ * lyxtext.h: add FontIterator class
* text.C (FontIterator, operator*, operator->, operator++): add
(rowBreakPoint, setRowWidth): adjust (fixing a
2004-02-04 André Pönitz <poenitz@gmx.net>
* BufferView.[Ch] (insertInset):
- * BufferView_pimpl.[Ch] (insertInset): remove unneeded return value
+ * BufferView_pimpl.[Ch] (insertInset): remove unneeded return value
* text2.C:
* text3.C: adjust
2004-02-03 Alfredo Braunstein <abraunst@lyx.org>
- * BufferView_pimpl.C (dispatch): remove call to LCursor::dispatch
+ * BufferView_pimpl.C (dispatch): remove call to LCursor::dispatch
on the default clause of the switch
- * lyxfunc.C (dispatch): call BufferView::dispatch if the event
+ * lyxfunc.C (dispatch): call BufferView::dispatch if the event
wasn't catched by LCursor::dispatch
2004-02-03 André Pönitz <poenitz@gmx.net>
* lyxfunc.C: adjust
- * lyxtext.h (firstPar, lastPar): remove dead functions
+ * lyxtext.h (firstPar, lastPar): remove dead functions
* text.C:
* text2.C:
// Start the real execution loop.
singleton_->priv_exec(argc, argv);
}
-
+
LyX & LyX::ref()
{
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) {
case SIGHUP:
- lyxerr << "\nlyx: SIGHUP signal caught" << endl;
- break;
- case SIGINT:
- // no comments
+ lyxerr << "\nlyx: SIGHUP signal caught\nBye." << endl;
break;
case SIGFPE:
- lyxerr << "\nlyx: SIGFPE signal caught" << endl;
+ lyxerr << "\nlyx: SIGFPE signal caught\nBye." << endl;
break;
case SIGSEGV:
- lyxerr << "\nlyx: SIGSEGV signal caught" << endl;
- lyxerr <<
- "Sorry, you have found a bug in LyX. "
- "Please read the bug-reporting instructions "
- "in Help->Introduction and send us a bug report, "
- "if necessary. Thanks !" << endl;
+ lyxerr << "\nlyx: SIGSEGV signal caught\n"
+ "Sorry, you have found a bug in LyX. "
+ "Please read the bug-reporting instructions "
+ "in Help->Introduction and send us a bug report, "
+ "if necessary. Thanks !\nBye." << endl;
break;
+ case SIGINT:
case SIGTERM:
// no comments
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
signal(SIGFPE, SIG_DFL);
signal(SIGSEGV, SIG_DFL);
signal(SIGTERM, SIG_DFL);
- signal(SIGPIPE, SIG_DFL);
-
- LyX::cref().emergencyCleanup();
- lyxerr << "Bye." << endl;
- if (err_sig!= SIGHUP &&
- (!GetEnv("LYXDEBUG").empty() || err_sig == SIGSEGV))
+ if (err_sig == SIGSEGV ||
+ (err_sig != SIGHUP && !GetEnv("LYXDEBUG").empty()))
lyx::support::abort();
exit(0);
}
signal(SIGSEGV, error_handler);
signal(SIGINT, error_handler);
signal(SIGTERM, error_handler);
- signal(SIGPIPE, error_handler);
+ // SIGPIPE can be safely ignored.
bool const explicit_userdir = setLyxPaths();