Fix some bugs in non blocking pipe writing

This commit is contained in:
Maxime Coste 2017-02-03 18:40:03 +00:00
parent f500af9023
commit cb2e1a17b3

View File

@ -215,12 +215,13 @@ std::pair<String, int> ShellManager::eval(
(size_t)contents.length()); (size_t)contents.length());
if (size > 0) if (size > 0)
contents = contents.substr(ByteCount{(int)size}); contents = contents.substr(ByteCount{(int)size});
if (size == -1 and (errno = EAGAIN or errno == EWOULDBLOCK)) if (size == -1 and (errno == EAGAIN or errno == EWOULDBLOCK))
return; return;
if (size < 0 or contents.empty()) if (size < 0 or contents.empty())
{ {
pipe.close_write_fd(); pipe.close_write_fd();
watcher.disable(); watcher.disable();
return;
} }
} }
}) })