Skip to content

Commit e0aa3c7

Browse files
committed
try to fix ::ioctl(Private::in.fd(), FIONREAD, &nread)
1 parent 08fb483 commit e0aa3c7

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

cpp-terminal/private/file.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "cpp-terminal/private/file.hpp"
1111

1212
#include "cpp-terminal/private/exception.hpp"
13+
#include "cpp-terminal/tty.hpp"
1314

1415
#include <cstdio>
1516
#include <new>
@@ -143,14 +144,7 @@ std::string Term::Private::InputFileHandler::read() const
143144
static const constexpr std::size_t posix_max_input{256};
144145
#endif
145146
static std::size_t nread{std::max(max_input, posix_max_input)};
146-
try
147-
{
148-
Term::Private::Errno().check_if(::ioctl(Private::in.fd(), FIONREAD, &nread) != 0).throw_exception("::ioctl(Private::in.fd(), FIONREAD, &nread)"); //NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
149-
}
150-
catch(const ErrnoException& exception)
151-
{
152-
if(exception.code() != 25 && exception.code() != 0 && exception.code() != 19) throw;
153-
}
147+
if(is_stdin_a_tty()) Term::Private::Errno().check_if(::ioctl(Private::in.fd(), FIONREAD, &nread) != 0).throw_exception("::ioctl(Private::in.fd(), FIONREAD, &nread)"); //NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
154148
std::string ret(nread, '\0');
155149
if(nread != 0)
156150
{

0 commit comments

Comments
 (0)