summaryrefslogtreecommitdiff
path: root/lib/OutPipe.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/OutPipe.cc')
-rw-r--r--lib/OutPipe.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/OutPipe.cc b/lib/OutPipe.cc
new file mode 100644
index 0000000..456a5bd
--- /dev/null
+++ b/lib/OutPipe.cc
@@ -0,0 +1,31 @@
+#include "OutPipe.h"
+#include "Input.h"
+
+OutPipe::OutPipe() : Handle(pipe(p, 1)), hooked(0) { }
+
+OutPipe::~OutPipe() {
+ if (hooked) {
+ ::close(0);
+ dup(Stdin.GetHandle());
+ }
+}
+
+void OutPipe::Hook() {
+ if (!hooked) {
+ hooked = 1;
+ ::close(0);
+ dup(p[0]);
+ }
+}
+
+bool OutPipe::CanWrite() {
+ return false;
+}
+
+bool OutPipe::CanRead() {
+ return true;
+}
+
+String OutPipe::GetName() {
+ return (String("Input pipe from stdout (") + (hooked ? "" : "not ") + "hooked)");
+}