Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6171


Ignore:
Timestamp:
Nov 27, 2009, 12:30:29 PM (15 years ago)
Author:
scheusso
Message:

fixed problem with ioconsole not restoring terminal settings when a segfault/sigabrt/etc occured

Location:
code/branches/presentation2/src/libraries/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/libraries/core/IOConsole.cc

    r6141 r6171  
    5151        {
    5252            level = (*text)[0];
    53             if (level == -1 || level >= 1 && level <= 6)
     53            if (level == -1 || (level >= 1 && level <= 6))
    5454            {
    5555                *text = text->substr(1);
     
    117117namespace orxonox
    118118{
     119    termios* IOConsole::originalTerminalSettings_s = 0;
     120   
    119121    namespace EscapeMode
    120122    {
     
    133135        , bStatusPrinted_(false)
    134136        , promptString_("orxonox # ")
    135         , originalTerminalSettings_(new termios())
    136137    {
    137138        this->setTerminalMode();
     
    168169
    169170        resetTerminalMode();
    170         delete this->originalTerminalSettings_;
    171171        this->shell_->destroy();
    172172
     
    369369    {
    370370        termios new_settings;
    371 
    372         tcgetattr(0, this->originalTerminalSettings_);
    373         new_settings = *this->originalTerminalSettings_;
     371        IOConsole::originalTerminalSettings_s = new termios();
     372
     373        tcgetattr(0, this->originalTerminalSettings_s);
     374        new_settings = *this->originalTerminalSettings_s;
    374375        new_settings.c_lflag &= ~(ICANON | ECHO);
    375376        //new_settings.c_lflag |= (ISIG | IEXTEN);
     
    377378        new_settings.c_cc[VMIN]  = 0;
    378379        tcsetattr(0, TCSANOW, &new_settings);
    379     }
    380 
    381     void IOConsole::resetTerminalMode()
    382     {
    383         tcsetattr(0, TCSANOW, IOConsole::originalTerminalSettings_);
     380        atexit(&IOConsole::resetTerminalMode);
     381    }
     382
     383    /*static*/ void IOConsole::resetTerminalMode()
     384    {
     385        if(IOConsole::originalTerminalSettings_s)
     386        {
     387            tcsetattr(0, TCSANOW, IOConsole::originalTerminalSettings_s);
     388            delete IOConsole::originalTerminalSettings_s;
     389            IOConsole::originalTerminalSettings_s = 0;
     390        }
    384391    }
    385392
  • code/branches/presentation2/src/libraries/core/IOConsole.h

    r6140 r6171  
    6060    private:
    6161        void setTerminalMode();
    62         void resetTerminalMode();
     62        static void resetTerminalMode();
    6363        void getTerminalSize();
    6464        bool willPrintStatusLines();
     
    9393
    9494#ifdef ORXONOX_PLATFORM_UNIX
    95         termios*                originalTerminalSettings_;
     95        static termios*         originalTerminalSettings_s;
    9696#elif defined(ORXONOX_PLATFORM_WINDOWS)
    9797        void moveCursor(int dx, int dy);
Note: See TracChangeset for help on using the changeset viewer.