Restoring terminal settings after daemonizing.
Signed-off-by: Dom Rodriguez <shymega@shymega.org.uk>
This commit is contained in:
parent
4ed0141389
commit
c32e7c607e
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "arch/unix/XArchUnix.h"
|
||||
#include "base/Log.h"
|
||||
#include "barrier/App.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -86,6 +87,8 @@ ArchDaemonUnix::daemonize(const char* name, DaemonFunc func)
|
|||
break;
|
||||
|
||||
default:
|
||||
// first restore terminal settings
|
||||
App::instance().getEvents()->restoreTerminal();
|
||||
// parent exits
|
||||
exit(0);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
virtual Event::Type getRegisteredType(const std::string& name) const;
|
||||
void* getSystemTarget();
|
||||
virtual void waitForReady() const;
|
||||
virtual void restoreTerminal() const { m_parentStream.restoreTerminal(); }
|
||||
|
||||
private:
|
||||
UInt32 saveEvent(const Event& event);
|
||||
|
|
|
@ -184,6 +184,11 @@ public:
|
|||
be added.
|
||||
*/
|
||||
virtual void waitForReady() const = 0;
|
||||
//! Restore the terminal settings
|
||||
/*!
|
||||
Called to restore the terminal settings after daemonizing.
|
||||
*/
|
||||
virtual void restoreTerminal() const = 0;
|
||||
|
||||
//@}
|
||||
//! @name accessors
|
||||
|
|
|
@ -57,4 +57,10 @@ bool NonBlockingStream::try_read_char(char &ch) const
|
|||
return false;
|
||||
}
|
||||
|
||||
void NonBlockingStream::restoreTerminal() const
|
||||
{
|
||||
tcsetattr(_fd, TCSANOW, _p_ta_previous);
|
||||
fcntl(_fd, F_SETFL, _cntl_previous);
|
||||
}
|
||||
|
||||
#endif // !defined(_WIN32)
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
~NonBlockingStream();
|
||||
|
||||
bool try_read_char(char &ch) const;
|
||||
void restoreTerminal(void) const;
|
||||
|
||||
private:
|
||||
int _fd;
|
||||
|
|
|
@ -64,4 +64,5 @@ public:
|
|||
MOCK_METHOD0(forClipboard, ClipboardEvents&());
|
||||
MOCK_METHOD0(forFile, FileEvents&());
|
||||
MOCK_CONST_METHOD0(waitForReady, void());
|
||||
MOCK_CONST_METHOD0(restoreTerminal, void());
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue