#1183 Disable stdin handler if not available.
This commit is contained in:
parent
7a1ff6bfed
commit
e57798360f
5 changed files with 100 additions and 14 deletions
|
@ -31,8 +31,11 @@
|
|||
xmrig::Console::Console(IConsoleListener *listener)
|
||||
: m_listener(listener)
|
||||
{
|
||||
m_tty = new uv_tty_t;
|
||||
if (!isSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_tty = new uv_tty_t;
|
||||
m_tty->data = this;
|
||||
uv_tty_init(uv_default_loop(), m_tty, 0, 1);
|
||||
|
||||
|
@ -53,6 +56,10 @@ xmrig::Console::~Console()
|
|||
|
||||
void xmrig::Console::stop()
|
||||
{
|
||||
if (!m_tty) {
|
||||
return;
|
||||
}
|
||||
|
||||
uv_tty_reset_mode();
|
||||
|
||||
Handle::close(m_tty);
|
||||
|
@ -60,6 +67,13 @@ void xmrig::Console::stop()
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::Console::isSupported() const
|
||||
{
|
||||
const uv_handle_type type = uv_guess_handle(0);
|
||||
return type == UV_TTY || type == UV_NAMED_PIPE;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Console::onAllocBuffer(uv_handle_t *handle, size_t, uv_buf_t *buf)
|
||||
{
|
||||
auto console = static_cast<Console*>(handle->data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue