1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
17 #pragma implementation
25 #include "lyx_gui_misc.h"
27 #include "support/path.h"
28 #include "support/filetools.h"
30 #include "bufferlist.h"
32 #include "support/FileInfo.h"
33 #include "lastfiles.h"
35 #include "lyxserver.h"
39 #include "MenuBackend.h"
40 #include "ToolbarDefaults.h"
43 #include "converter.h"
45 #include "support/os.h"
49 #ifndef CXX_GLOBAL_CSTD
53 extern void LoadLyXFile(string const &);
54 extern void QuitLyX();
58 string system_tempdir;
59 string user_lyxdir; // Default $HOME/.lyx
61 // Should this be kept global? Asger says Yes.
64 LastFiles * lastfiles;
66 // This is the global bufferlist object
67 BufferList bufferlist;
69 LyXServer * lyxserver = 0;
70 // this should be static, but I need it in buffer.C
71 bool finished = false; // flag, that we are quitting the program
73 // convenient to have it here.
74 boost::scoped_ptr<kb_keymap> toplevel_keymap;
77 LyX::LyX(int * argc, char * argv[])
79 // Prevent crash with --help
83 // Here we need to parse the command line. At least
84 // we need to parse for "-dbg" and "-help"
85 bool gui = easyParse(argc, argv);
87 // Global bindings (this must be done as early as possible.) (Lgb)
88 toplevel_keymap.reset(new kb_keymap);
89 defaultKeyBindings(toplevel_keymap.get());
91 // Make the GUI object, and let it take care of the
92 // command line arguments that concerns it.
93 lyxerr[Debug::INIT] << "Initializing LyXGUI..." << endl;
94 lyxGUI = new LyXGUI(this, argc, argv, gui);
95 lyxerr[Debug::INIT] << "Initializing LyXGUI...done" << endl;
97 // Now the GUI and LyX have taken care of their arguments, so
98 // the only thing left on the command line should be
99 // filenames. Let's check anyway.
100 for (int argi = 1; argi < *argc ; ++argi) {
101 if (argv[argi][0] == '-') {
102 lyxerr << _("Wrong command line option `")
104 << _("'. Exiting.") << endl;
109 // Initialization of LyX (reads lyxrc and more)
110 lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
112 lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
116 // Load the files specified in the command line.
118 lyxerr[Debug::INFO] << "Opening document..." << endl;
119 else if ((*argc) > 2)
120 lyxerr[Debug::INFO] << "Opening documents..." << endl;
122 Buffer * last_loaded = 0;
124 for (int argi = (*argc) - 1; argi >= 1; --argi) {
125 Buffer * loadb = bufferlist.loadLyXFile(argv[argi]);
132 string const splash =
133 i18nLibFileSearch("examples", "splash.lyx");
134 lyxerr[Debug::INIT] << "Opening splash document "
135 << splash << "..." << endl;
136 Buffer * loadb = bufferlist.loadLyXFile(splash);
142 if (last_loaded != 0) {
143 lyxerr[Debug::INIT] << "Yes we loaded some files." << endl;
145 lyxGUI->regBuf(last_loaded);
148 // Execute batch commands if available
149 if (!batch_command.empty()) {
150 lyxerr << "About to handle -x '"
151 << batch_command << "'" << endl;
153 // no buffer loaded, create one
155 last_loaded = bufferlist.newFile("tmpfile", string());
157 // try to dispatch to last loaded buffer first
158 bool dispatched = last_loaded->dispatch(batch_command);
160 // if this was successful, return.
161 // Maybe we could do something more clever than aborting...
163 lyxerr << "We are done!" << endl;
168 // otherwise, let the GUI handle the batch command
169 lyxGUI->regBuf(last_loaded);
170 lyxGUI->getLyXView()->getLyXFunc()->dispatch(batch_command);
175 // Let the ball begin...
180 // A destructor is always necessary (asierra-970604)
188 extern "C" void error_handler(int err_sig);
190 void LyX::init(bool gui)
192 // Install the signal handlers
193 signal(SIGHUP, error_handler);
194 signal(SIGFPE, error_handler);
195 signal(SIGSEGV, error_handler);
196 signal(SIGINT, error_handler);
197 signal(SIGTERM, error_handler);
200 // Determine path of binary
204 string binpath = os::binpath();
205 string binname = os::binname();
206 fullbinpath = binpath;
208 if (binpath.empty()) {
209 lyxerr << _("Warning: could not determine path of binary.")
211 << _("If you have problems, try starting LyX with an absolute path.")
214 lyxerr[Debug::INIT] << "Path of binary: " << binpath << endl;
217 // Determine system directory.
220 // Directories are searched in this order:
221 // 1) -sysdir command line parameter
222 // 2) LYX_DIR_11x environment variable
223 // 3) Maybe <path of binary>/TOP_SRCDIR/lib
224 // 4) <path of binary>/../share/<name of binary>/
225 // 4a) repeat 4 after following the Symlink if <path of
226 // binary> is a symbolic link.
227 // 5) hardcoded lyx_dir
228 // The directory is checked for the presence of the file
229 // "chkconfig.ltx", and if that is present, the directory
230 // is accepted as the system directory.
231 // If no chkconfig.ltx file is found, a warning is given,
232 // and the hardcoded lyx_dir is used.
234 // If we had a command line switch, system_lyxdir is already set
236 if (!system_lyxdir.empty())
237 searchpath= MakeAbsPath(system_lyxdir) + ';';
239 // LYX_DIR_11x environment variable
240 string const lyxdir = GetEnvPath("LYX_DIR_11x");
242 if (!lyxdir.empty()) {
243 lyxerr[Debug::INIT] << "LYX_DIR_11x: " << lyxdir << endl;
244 searchpath += lyxdir + ';';
247 // <path of binary>/TOP_SRCDIR/lib
248 build_lyxdir = MakeAbsPath("../lib", binpath);
249 if (!FileSearch(build_lyxdir, "lyxrc.defaults").empty()) {
250 searchpath += MakeAbsPath(AddPath(TOP_SRCDIR, "lib"),
252 lyxerr[Debug::INIT] << "Checking whether LyX is run in "
253 "place... yes" << endl;
256 << "Checking whether LyX is run in place... no"
258 build_lyxdir.erase();
263 // Path of binary/../share/name of binary/
264 searchpath += NormalizePath(AddPath(binpath, "../share/") +
265 OnlyFilename(binname)) + ';';
268 FileInfo file(fullbinpath, true);
269 followlink = file.isLink();
272 if (LyXReadLink(fullbinpath, link)) {
274 binpath = MakeAbsPath(OnlyPath(fullbinpath));
280 } while (followlink);
283 searchpath += LYX_DIR;
285 // If debugging, show complete search path
286 lyxerr[Debug::INIT] << "System directory search path: "
287 << searchpath << endl;
289 string const filename = "chkconfig.ltx";
290 string const temp = FileOpenSearch(searchpath, filename, string());
291 system_lyxdir = OnlyPath(temp);
293 // Reduce "path/../path" stuff out of system directory
294 system_lyxdir = NormalizePath(system_lyxdir);
296 bool path_shown = false;
298 // Warn if environment variable is set, but unusable
299 if (!lyxdir.empty()) {
300 if (system_lyxdir != NormalizePath(lyxdir)) {
301 lyxerr <<_("LYX_DIR_11x environment variable no good.")
303 << _("System directory set to: ")
304 << system_lyxdir << endl;
309 // Warn the user if we couldn't find "chkconfig.ltx"
310 if (system_lyxdir == "./") {
311 lyxerr <<_("LyX Warning! Couldn't determine system directory. ")
312 <<_("Try the '-sysdir' command line parameter or ")
313 <<_("set the environment variable LYX_DIR_11x to the "
314 "LyX system directory ")
315 << _("containing the file `chkconfig.ltx'.") << endl;
317 FileInfo fi(LYX_DIR);
319 lyxerr << "Couldn't even find the default LYX_DIR." << endl
320 << "Giving up." << endl;
323 lyxerr << _("Using built-in default ")
324 << LYX_DIR << _(" but expect problems.")
327 lyxerr << _("Expect problems.") << endl;
329 system_lyxdir = LYX_DIR;
333 // Report the system directory if debugging is on
335 lyxerr[Debug::INIT] << "System directory: '"
336 << system_lyxdir << '\'' << endl;
339 // Determine user lyx-dir
342 // Directories are searched in this order:
343 // 1) -userdir command line parameter
344 // 2) LYX_USERDIR_11x environment variable
345 // 3) $HOME/.<name of binary>
347 // If we had a command line switch, user_lyxdir is already set
348 bool explicit_userdir = true;
349 if (user_lyxdir.empty()) {
351 // LYX_USERDIR_11x environment variable
352 user_lyxdir = GetEnvPath("LYX_USERDIR_11x");
355 if (user_lyxdir.empty())
356 user_lyxdir = AddPath(GetEnvPath("HOME"),
357 string(".") + PACKAGE);
358 explicit_userdir = false;
361 lyxerr[Debug::INIT] << "User LyX directory: '"
362 << user_lyxdir << '\'' << endl;
364 // Check that user LyX directory is ok. We don't do that if
365 // running in batch mode.
367 queryUserLyXDir(explicit_userdir);
373 // Shine up lyxrc defaults
376 // Default template path: system_dir/templates
377 if (lyxrc.template_path.empty()){
378 lyxrc.template_path = AddPath(system_lyxdir, "templates");
381 // Default lastfiles file: $HOME/.lyx/lastfiles
382 if (lyxrc.lastfiles.empty()){
383 lyxrc.lastfiles = AddName(user_lyxdir, "lastfiles");
386 // Disable gui when either lyxrc or easyparse says so
388 lyxrc.use_gui = false;
390 // Calculate screen dpi as average of x-DPI and y-DPI:
392 lyxrc.dpi = getScreenDPI();
393 lyxerr[Debug::INIT] << "DPI setting detected to be "
394 << lyxrc.dpi + 0.5 << endl;
396 lyxrc.dpi = 1; // I hope this is safe
400 // Read configuration files
403 readRcFile("lyxrc.defaults");
404 system_lyxrc = lyxrc;
405 system_formats = formats;
406 system_converters = converters;
407 system_lcolor = lcolor;
409 // If there is a preferences file we read that instead
410 // of the old lyxrc file.
411 if (!readRcFile("preferences"))
415 readEncodingsFile("encodings");
417 readLanguagesFile("languages");
420 lyxerr[Debug::INIT] << "Reading layouts..." << endl;
423 // Ensure that we have really read a bind file, so that LyX is
425 lyxrc.readBindFileIfNeeded();
428 readUIFile(lyxrc.ui_file);
430 // Bind the X dead keys to the corresponding LyX functions if
432 if (lyxrc.override_x_deadkeys)
433 deadKeyBindings(toplevel_keymap.get());
435 if (lyxerr.debugging(Debug::LYXRC)) {
439 // Create temp directory
440 os::setTmpDir(CreateLyXTmpDir(lyxrc.tempdir_path));
441 system_tempdir = os::getTmpDir();
442 if (lyxerr.debugging(Debug::INIT)) {
443 lyxerr << "LyX tmp dir: `" << system_tempdir << '\'' << endl;
446 // load the lastfiles mini-database
447 lyxerr[Debug::INIT] << "Reading lastfiles `"
448 << lyxrc.lastfiles << "'..." << endl;
449 lastfiles = new LastFiles(lyxrc.lastfiles,
450 lyxrc.check_lastfiles,
451 lyxrc.num_lastfiles);
453 // start up the lyxserver. (is this a bit early?) (Lgb)
454 // 0.12 this will be way to early, we need the GUI to be initialized
455 // first, so move it for now.
456 // lyxserver = new LyXServer;
460 // These are the default bindings known to LyX
461 void LyX::defaultKeyBindings(kb_keymap * kbmap)
463 kbmap->bind("Right", LFUN_RIGHT);
464 kbmap->bind("Left", LFUN_LEFT);
465 kbmap->bind("Up", LFUN_UP);
466 kbmap->bind("Down", LFUN_DOWN);
468 kbmap->bind("Tab", LFUN_TAB);
469 kbmap->bind("ISO_Left_Tab", LFUN_TAB); // jbl 2001-23-02
471 kbmap->bind("Home", LFUN_HOME);
472 kbmap->bind("End", LFUN_END);
473 kbmap->bind("Prior", LFUN_PRIOR);
474 kbmap->bind("Next", LFUN_NEXT);
476 kbmap->bind("Return", LFUN_BREAKPARAGRAPH);
477 //kbmap->bind("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
479 kbmap->bind("Delete", LFUN_DELETE);
480 kbmap->bind("BackSpace", LFUN_BACKSPACE);
482 // kbmap->bindings to enable the use of the numeric keypad
484 //kbmap->bind("KP_0", LFUN_SELFINSERT);
485 //kbmap->bind("KP_Decimal", LFUN_SELFINSERT);
486 kbmap->bind("KP_Enter", LFUN_BREAKPARAGRAPH);
487 //kbmap->bind("KP_1", LFUN_SELFINSERT);
488 //kbmap->bind("KP_2", LFUN_SELFINSERT);
489 //kbmap->bind("KP_3", LFUN_SELFINSERT);
490 //kbmap->bind("KP_4", LFUN_SELFINSERT);
491 //kbmap->bind("KP_5", LFUN_SELFINSERT);
492 //kbmap->bind("KP_6", LFUN_SELFINSERT);
493 //kbmap->bind("KP_Add", LFUN_SELFINSERT);
494 //kbmap->bind("KP_7", LFUN_SELFINSERT);
495 //kbmap->bind("KP_8", LFUN_SELFINSERT);
496 //kbmap->bind("KP_9", LFUN_SELFINSERT);
497 //kbmap->bind("KP_Divide", LFUN_SELFINSERT);
498 //kbmap->bind("KP_Multiply", LFUN_SELFINSERT);
499 //kbmap->bind("KP_Subtract", LFUN_SELFINSERT);
500 kbmap->bind("KP_Right", LFUN_RIGHT);
501 kbmap->bind("KP_Left", LFUN_LEFT);
502 kbmap->bind("KP_Up", LFUN_UP);
503 kbmap->bind("KP_Down", LFUN_DOWN);
504 kbmap->bind("KP_Home", LFUN_HOME);
505 kbmap->bind("KP_End", LFUN_END);
506 kbmap->bind("KP_Prior", LFUN_PRIOR);
507 kbmap->bind("KP_Next", LFUN_NEXT);
509 kbmap->bind("C-Tab", LFUN_TABINSERT); // ale970515
510 kbmap->bind("S-Tab", LFUN_SHIFT_TAB); // jug20000522
511 kbmap->bind("S-ISO_Left_Tab", LFUN_SHIFT_TAB); // jbl 2001-23-02
515 // LyX can optionally take over the handling of deadkeys
516 void LyX::deadKeyBindings(kb_keymap * kbmap)
518 // bindKeyings for transparent handling of deadkeys
519 // The keysyms are gotten from XFree86 X11R6
520 kbmap->bind("~C-~S-~M-dead_acute", LFUN_ACUTE);
521 kbmap->bind("~C-~S-~M-dead_breve", LFUN_BREVE);
522 kbmap->bind("~C-~S-~M-dead_caron", LFUN_CARON);
523 kbmap->bind("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
524 kbmap->bind("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
525 kbmap->bind("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
526 kbmap->bind("~C-~S-~M-dead_abovedot", LFUN_DOT);
527 kbmap->bind("~C-~S-~M-dead_grave", LFUN_GRAVE);
528 kbmap->bind("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
529 kbmap->bind("~C-~S-~M-dead_macron", LFUN_MACRON);
530 // nothing with this name
531 // kbmap->bind("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON);
532 kbmap->bind("~C-~S-~M-dead_tilde", LFUN_TILDE);
533 kbmap->bind("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT);
534 // nothing with this name either...
535 //kbmap->bind("~C-~S-~M-dead_underbar", LFUN_UNDERBAR);
536 kbmap->bind("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
537 kbmap->bind("~C-~S-~M-dead_tie", LFUN_TIE);
538 kbmap->bind("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
542 // This one is not allowed to use anything on the main form, since that
543 // one does not exist yet. (Asger)
544 void LyX::queryUserLyXDir(bool explicit_userdir)
546 // Does user directory exist?
547 FileInfo fileInfo(user_lyxdir);
548 if (fileInfo.isOK() && fileInfo.isDir()) {
552 first_start = !explicit_userdir;
555 // If the user specified explicitely a directory, ask whether
556 // to create it (otherwise, always create it)
557 if (explicit_userdir &&
558 !AskQuestion(_("You have specified an invalid LyX directory."),
559 _("It is needed to keep your own configuration."),
560 _("Should I try to set it up for you (recommended)?"))) {
561 lyxerr << _("Running without personal LyX directory.") << endl;
562 // No, let's use $HOME instead.
563 user_lyxdir = GetEnvPath("HOME");
567 // Tell the user what is going on
568 lyxerr << _("LyX: Creating directory ") << user_lyxdir
569 << _(" and running configure...") << endl;
571 // Create directory structure
572 if (!createDirectory(user_lyxdir, 0755)) {
573 // Failed, let's use $HOME instead.
574 user_lyxdir = GetEnvPath("HOME");
575 lyxerr << _("Failed. Will use ") << user_lyxdir
576 << _(" instead.") << endl;
580 // Run configure in user lyx directory
582 ::system(AddName(system_lyxdir, "configure").c_str());
583 lyxerr << "LyX: " << _("Done!") << endl;
587 // Read the rc file `name'
588 bool LyX::readRcFile(string const & name)
590 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
592 string const lyxrc_path = LibFileSearch(string(), name);
593 if (!lyxrc_path.empty()){
594 lyxerr[Debug::INIT] << "Found " << name
595 << " in " << lyxrc_path << endl;
596 if (lyxrc.read(lyxrc_path) < 0) {
597 WriteAlert(_("LyX Warning!"),
598 _("Error while reading ") + lyxrc_path + ".",
599 _("Using built-in defaults."));
604 lyxerr[Debug::INIT] << "Could not find " << name << endl;
611 // Read the ui file `name'
612 void LyX::readUIFile(string const & name)
620 struct keyword_item uitags[ui_last-1] = {
621 { "menuset", ui_menuset },
622 { "toolbar", ui_toolbar }
625 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
627 string const ui_path = LibFileSearch("ui", name, "ui");
629 if (ui_path.empty()) {
630 lyxerr[Debug::INIT] << "Could not find " << name << endl;
631 menubackend.defaults();
635 lyxerr[Debug::INIT] << "Found " << name
636 << " in " << ui_path << endl;
637 LyXLex lex(uitags, ui_last - 1);
638 lex.setFile(ui_path);
640 lyxerr << "Unable to set LyXLeX for ui file: " << ui_path
644 if (lyxerr.debugging(Debug::PARSER))
645 lex.printTable(lyxerr);
650 menubackend.read(lex);
654 toolbardefaults.read(lex);
658 if(!strip(lex.getString()).empty())
659 lex.printError("LyX::ReadUIFile: "
660 "Unknown menu tag: `$$Token'");
667 // Read the languages file `name'
668 void LyX::readLanguagesFile(string const & name)
670 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
672 string const lang_path = LibFileSearch(string(), name);
673 if (lang_path.empty()) {
674 lyxerr[Debug::INIT] << "Could not find " << name << endl;
675 languages.setDefaults();
678 languages.read(lang_path);
682 // Read the encodings file `name'
683 void LyX::readEncodingsFile(string const & name)
685 lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
687 string const enc_path = LibFileSearch(string(), name);
688 if (enc_path.empty()) {
689 lyxerr[Debug::INIT] << "Could not find " << name << endl;
692 encodings.read(enc_path);
698 // Set debugging level and report result to user
699 void setDebuggingLevel(string const & dbgLevel)
701 lyxerr << _("Setting debug level to ") << dbgLevel << endl;
702 lyxerr.level(Debug::value(dbgLevel));
703 Debug::showLevel(lyxerr, lyxerr.level());
707 // Give command line help
708 void commandLineHelp()
710 lyxerr << "LyX " LYX_VERSION << " of " LYX_RELEASE << endl;
712 _("Usage: lyx [ command line switches ] [ name.lyx ... ]\n"
713 "Command line switches (case sensitive):\n"
714 "\t-help summarize LyX usage\n"
715 "\t-userdir dir try to set user directory to dir\n"
716 "\t-sysdir dir try to set system directory to dir\n"
717 "\t-geometry WxH+X+Y set geometry of the main window\n"
718 "\t-dbg feature[,feature]...\n"
719 " select the features to debug.\n"
720 " Type `lyx -dbg' to see the list of features\n"
721 "\t-x [--execute] command\n"
722 " where command is a lyx command.\n"
723 "\t-e [--export] fmt\n"
724 " where fmt is the export format of choice.\n"
725 "\t-i [--import] fmt file.xxx\n"
726 " where fmt is the import format of choice\n"
727 " and file.xxx is the file to be imported.\n"
728 "Check the LyX man page for more details.") << endl;
734 bool LyX::easyParse(int * argc, char * argv[])
737 int removeargs = 0; // used when options are read
738 for (int i = 1; i < *argc; ++i) {
739 string arg = argv[i];
741 // Check for -dbg int
744 setDebuggingLevel(argv[i + 1]);
747 lyxerr << _("List of supported debug flags:")
749 Debug::showTags(lyxerr);
753 // Check for "-sysdir"
754 else if (arg == "-sysdir") {
756 system_lyxdir = argv[i + 1];
759 lyxerr << _("Missing directory for -sysdir switch!")
764 // Check for "-userdir"
765 else if (arg == "-userdir") {
767 user_lyxdir = argv[i + 1];
770 lyxerr << _("Missing directory for -userdir switch!")
775 // Check for --help or -help
776 else if (arg == "--help" || arg == "-help") {
780 // Check for "-nw": No XWindows as for emacs this should
781 // give a LyX that could be used in a terminal window.
782 //else if (arg == "-nw") {
786 // Check for "-x": Execute commands
787 else if (arg == "-x" || arg == "--execute") {
789 batch_command = string(argv[i + 1]);
793 lyxerr << _("Missing command string after -x switch!") << endl;
795 // Argh. Setting gui to false segfaults..
799 else if (arg == "-e" || arg == "--export") {
801 string type(argv[i+1]);
803 batch_command = "buffer-export " + type;
806 lyxerr << _("Missing file type [eg latex, "
808 << arg << _(" switch!") << endl;
810 else if (arg == "-i" || arg == "--import") {
812 string type(argv[i+1]);
813 string file(argv[i+2]);
816 batch_command = "buffer-import " + type + " " + file;
817 lyxerr << "batch_command: "
818 << batch_command << endl;
821 lyxerr << _("Missing type [eg latex, "
823 << arg << _(" switch!") << endl;
826 if (removeargs > 0) {
827 // Now, remove used arguments by shifting
828 // the following ones removeargs places down.
829 (*argc) -= removeargs;
830 for (int j = i; j < (*argc); ++j)
831 argv[j] = argv[j + removeargs];
832 --i; // After shift, check this number again.
843 void error_handler(int err_sig)
847 lyxerr << "\nlyx: SIGHUP signal caught" << endl;
853 lyxerr << "\nlyx: SIGFPE signal caught" << endl;
856 lyxerr << "\nlyx: SIGSEGV signal caught" << endl;
858 "Sorry, you have found a bug in LyX."
859 " If possible, please read 'Known bugs'\n"
860 "under the Help menu and then send us "
861 "a full bug report. Thanks!" << endl;
868 // Deinstall the signal handlers
869 signal(SIGHUP, SIG_DFL);
870 signal(SIGINT, SIG_DFL);
871 signal(SIGFPE, SIG_DFL);
872 signal(SIGSEGV, SIG_DFL);
873 signal(SIGTERM, SIG_DFL);
875 bufferlist.emergencyWriteAll();
877 lyxerr << "Bye." << endl;
878 if (err_sig!= SIGHUP &&
879 (!GetEnv("LYXDEBUG").empty() || err_sig == SIGSEGV))