summaryrefslogtreecommitdiff
path: root/project2/processes/processStream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/processes/processStream.cpp')
-rw-r--r--project2/processes/processStream.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/project2/processes/processStream.cpp b/project2/processes/processStream.cpp
index 3067533..79945d2 100644
--- a/project2/processes/processStream.cpp
+++ b/project2/processes/processStream.cpp
@@ -1,11 +1,10 @@
#include "iHaveParameters.h"
#include "scriptLoader.h"
-#include "scopeObject.h"
+#include <processPipes.h>
#include "scripts.h"
#include "stream.h"
#include <exception>
#include <sys/wait.h>
-#include <misc.h>
SimpleMessageException(SubProcessFailedToStart);
SimpleMessageException(SubProcessFailed);
@@ -28,15 +27,9 @@ class ProcessStream : public Stream, IHaveParameters {
for (const Parameters::value_type & p : parameters) {
callProc.push_back(p.second(ec));
}
- int fds[2];
- popenrw(callProc, fds);
-
- ScopeObject doClose([&] {
- close(fds[0]);
- close(fds[1]);
- });
+ AdHoc::System::ProcessPipes fds(callProc, false, true, false);
char buf[BUFSIZ];
- while (ssize_t r = read(fds[1], buf, BUFSIZ) != 0) {
+ while (ssize_t r = read(fds.fdOut(), buf, BUFSIZ) != 0) {
if (r < 0) {
throw syscall_error(errno);
}
@@ -48,7 +41,7 @@ class ProcessStream : public Stream, IHaveParameters {
// ignore any error if the application is still running,
// but if there is already an exception being thrown, we don't
// want to throw another.
- if (status != 0 && !std::uncaught_exception()) {
+ if (status != 0 && !std::uncaught_exceptions()) {
throw SubProcessFailed(strerror(status));
}
}
@@ -56,4 +49,5 @@ class ProcessStream : public Stream, IHaveParameters {
const Variable path;
};
-DECLARE_LOADER("processstream", ProcessStream);
+NAMEDFACTORY("processstream", ProcessStream, StreamFactory);
+