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