runProgram(): Distinguish between empty input and no input

For example, if we call brotli with an empty input, it shouldn't read
from the caller's stdin.
This commit is contained in:
Eelco Dolstra 2017-03-15 14:40:47 +01:00
parent 042975ea8e
commit 25dff2b7db
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
5 changed files with 30 additions and 15 deletions

View file

@ -14,6 +14,7 @@
#include <cstdio>
#include <map>
#include <sstream>
#include <experimental/optional>
#ifndef HAVE_STRUCT_DIRENT_D_TYPE
#define DT_UNKNOWN 0
@ -232,7 +233,8 @@ pid_t startProcess(std::function<void()> fun, const ProcessOptions & options = P
/* Run a program and return its stdout in a string (i.e., like the
shell backtick operator). */
string runProgram(Path program, bool searchPath = false,
const Strings & args = Strings(), const string & input = "");
const Strings & args = Strings(),
const std::experimental::optional<std::string> & input = {});
class ExecError : public Error
{