Throw on errors in read callback
authorAlexey Spiridonov <lesha@fb.com>
Wed, 20 Apr 2016 19:08:29 +0000 (12:08 -0700)
committerFacebook Github Bot 0 <facebook-github-bot-0-bot@fb.com>
Wed, 20 Apr 2016 19:20:24 +0000 (12:20 -0700)
Summary: Before this fix, the callback would silently ignore `ret == -1` if the error isn't `EAGAIN`.

Reviewed By: spacedentist

Differential Revision: D3193845

fb-gh-sync-id: e4a7aa37de7dab8ebe0633dd9888d8adc11dd1c2
fbshipit-source-id: e4a7aa37de7dab8ebe0633dd9888d8adc11dd1c2

folly/Subprocess.h

index c70a1f4b8ad73b4d3d36bbfa4387026f51fdf580..2b6cbffc864f697d705b6ee7735750ccc550df95 100644 (file)
 #include <boost/container/flat_map.hpp>
 #include <boost/operators.hpp>
 
+#include <folly/Exception.h>
 #include <folly/File.h>
 #include <folly/FileUtil.h>
 #include <folly/gen/String.h>
@@ -683,6 +684,7 @@ class Subprocess {
         if (ret == -1 && errno == EAGAIN) {  // No more data for now
           return false;
         }
+        checkUnixError(ret, "read");
         if (ret == 0) {  // Reached end-of-file
           splitter.flush();  // Ignore return since the file is over anyway
           return true;