diff options
Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r-- | src/libutil/util.hh | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh index 07c027a1f919..ad0d377a4f5e 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -7,6 +7,7 @@ #include <dirent.h> #include <unistd.h> #include <signal.h> +#include <functional> #include <cstdio> @@ -237,6 +238,7 @@ class Pid int killSignal; public: Pid(); + Pid(pid_t pid); ~Pid(); void operator =(pid_t pid); operator pid_t(); @@ -252,6 +254,11 @@ public: void killUser(uid_t uid); +/* Fork a process that runs the given function, and return the child + pid to the caller. */ +pid_t startProcess(std::function<void()> fun, const string & errorPrefix = "error: "); + + /* Run a program and return its stdout in a string (i.e., like the shell backtick operator). */ string runProgram(Path program, bool searchPath = false, |