Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Last active August 10, 2018 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/782784e1ae1cce95fd8e506377b08952 to your computer and use it in GitHub Desktop.
Save zoffixznet/782784e1ae1cce95fd8e506377b08952 to your computer and use it in GitHub Desktop.
diff --git a/src/core/Proc.pm6 b/src/core/Proc.pm6
index 5cd1a1b..14da2d2 100644
--- a/src/core/Proc.pm6
+++ b/src/core/Proc.pm6
@@ -49,16 +49,24 @@ my class Proc {
}
if $merge {
- my $chan = Channel.new;
- $!out = IO::Pipe.new(:proc(self), :$chomp, :$enc, :$bin, nl-in => $nl,
- :on-read({ (try $chan.receive) // buf8 }),
- :on-close({ self!await-if-last-handle }));
- ++$!active-handles;
- @!pre-spawn.push({
- $!proc.stdout(:bin).merge($!proc.stderr(:bin)).act: { $chan.send($_) },
- done => { $chan.close },
- quit => { $chan.fail($_) }
- });
+ if nqp::istype($out, IO::Handle) {
+ @!pre-spawn.push: {
+ $!proc.bind-stdout: $out;
+ $!proc.bind-stderr: $out;
+ }
+ }
+ else {
+ my $chan = Channel.new;
+ $!out = IO::Pipe.new(:proc(self), :$chomp, :$enc, :$bin, nl-in => $nl,
+ :on-read({ (try $chan.receive) // buf8 }),
+ :on-close({ self!await-if-last-handle }));
+ ++$!active-handles;
+ @!pre-spawn.push({
+ $!proc.stdout(:bin).merge($!proc.stderr(:bin)).act: { $chan.send($_) },
+ done => { $chan.close },
+ quit => { $chan.fail($_) }
+ });
+ }
}
else {
if $out === True {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment