feat: add tool for noncanonical input

This commit is contained in:
Alexey Rybalchenko
2021-10-02 11:43:41 +02:00
parent d7fb01908c
commit 5fe2f53c7b
4 changed files with 55 additions and 56 deletions

View File

@@ -9,6 +9,7 @@
#include "Monitor.h"
#include "Common.h"
#include <fairmq/tools/IO.h>
#include <fairmq/tools/Strings.h>
#include <boost/interprocess/managed_shared_memory.hpp>
@@ -26,7 +27,6 @@
#include <iomanip>
#include <sstream>
#include <termios.h>
#include <poll.h>
#if FAIRMQ_HAS_STD_FILESYSTEM
@@ -49,32 +49,6 @@ namespace
namespace fair::mq::shmem
{
struct TerminalConfig
{
TerminalConfig()
{
termios t;
tcgetattr(STDIN_FILENO, &t); // get the current terminal I/O structure
t.c_lflag &= ~ICANON; // disable canonical input
t.c_lflag &= ~ECHO; // do not echo input chars
tcsetattr(STDIN_FILENO, TCSANOW, &t); // apply the new settings
}
TerminalConfig(const TerminalConfig&) = delete;
TerminalConfig(TerminalConfig&&) = delete;
TerminalConfig& operator=(const TerminalConfig&) = delete;
TerminalConfig& operator=(TerminalConfig&&) = delete;
~TerminalConfig()
{
termios t;
tcgetattr(STDIN_FILENO, &t); // get the current terminal I/O structure
t.c_lflag |= ICANON; // re-enable canonical input
t.c_lflag |= ECHO; // echo input chars
tcsetattr(STDIN_FILENO, TCSANOW, &t); // apply the new settings
}
};
void signalHandler(int signal)
{
gSignalStatus = signal;
@@ -339,7 +313,7 @@ void Monitor::Interactive()
cinfd[0].fd = fileno(stdin);
cinfd[0].events = POLLIN;
TerminalConfig tcfg;
tools::NonCanonicalInput nci;
LOG(info) << "\n";
PrintHelp();