summaryrefslogtreecommitdiff
path: root/lib/OutPipe.cc
diff options
context:
space:
mode:
authorPixel <Pixel>2001-11-26 23:11:40 +0000
committerPixel <Pixel>2001-11-26 23:11:40 +0000
commit3baa9d168c02a8734b95d1cc467601b6aaf2f6e4 (patch)
tree6c254e9d75dee5a1e305283788fea3d3fff2a445 /lib/OutPipe.cc
parent3aa63fcbddbce8762ad0f3f54d90ad985c0f9c41 (diff)
Big job here. Many bugs out. Hurray!!
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)");
+}