1. my class IO::Pipe is IO::Handle {
  2. has $.proc;
  3. method TWEAK(:$enc, :$bin, Mu :$PIO --> Nil) {
  4. if $bin {
  5. die X::IO::BinaryAndEncoding.new if nqp::isconcrete($enc);
  6. }
  7. else {
  8. my $encoding = Rakudo::Internals.NORMALIZE_ENCODING($enc || 'utf-8');
  9. nqp::bindattr(self, IO::Handle, '$!encoding', $encoding);
  10. my $decoder := Rakudo::Internals::VMBackedDecoder.new($encoding, :translate-nl);
  11. $decoder.set-line-separators($.nl-in.list);
  12. nqp::bindattr(self, IO::Handle, '$!decoder', $decoder);
  13. }
  14. nqp::bindattr(self, IO::Handle, '$!PIO', nqp::decont($PIO));
  15. }
  16. method close(IO::Pipe:D:) {
  17. my $PIO := nqp::getattr(nqp::decont(self), IO::Handle, '$!PIO');
  18. $!proc.status( nqp::closefh_i($PIO) ) if nqp::defined($PIO);
  19. nqp::bindattr(nqp::decont(self), IO::Handle, '$!PIO', Mu);
  20. $!proc;
  21. }
  22. method IO { IO::Path }
  23. method path { IO::Path }
  24. }