Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created June 17, 2017 11:20
Show Gist options
  • Save zoffixznet/a8c5f2eb3ca064044bbb04e947a3291b to your computer and use it in GitHub Desktop.
Save zoffixznet/a8c5f2eb3ca064044bbb04e947a3291b to your computer and use it in GitHub Desktop.
diff --git a/src/core/Proc.pm b/src/core/Proc.pm
index 955e26a..3e14816 100644
--- a/src/core/Proc.pm
+++ b/src/core/Proc.pm
@@ -21,7 +21,9 @@ my class Proc {
Str :$enc, Str:D :$nl = "\n", :$signal --> Nil) {
@!command = |$command if $command;
if nqp::istype($in, IO::Handle) && $in.DEFINITE {
- @!pre-spawn.push({ $!proc.bind-stdin($in) });
+ @!pre-spawn.push({
+ $!proc.bind-stdin($in);
+ });
}
elsif $in === True {
$!in = IO::Pipe.new(:proc(self), :$chomp, :$enc, :$bin, nl-out => $nl,
@@ -51,14 +53,21 @@ my class Proc {
if $out === True {
my $chan = Channel.new;
$!out = IO::Pipe.new(:proc(self), :$chomp, :$enc, :$bin, nl-in => $nl,
- :on-read({ (try $chan.receive) // buf8.new }),
+ :on-read({
+ my $rec = try $chan.receive;
+ $! and say "Error!!! $!.^name()";
+ $rec // buf8.new;
+ }),
:on-close({ self!await-if-last-handle }),
:bin-supply({ $chan.Supply }));
$!active-handles++;
@!pre-spawn.push({
- $!proc.stdout(:bin).tap: { $chan.send($_) },
- done => { $chan.close },
- quit => { $chan.fail($_) }
+ $!proc.stdout(:bin).tap: {
+ dd ["stdout tap {@!command[]}", 'sending'];
+ $chan.send($_) },
+ done => { dd ["stdout tap {@!command[]}", 'donning']; $chan.close
+ },
+ quit => { dd ["stdout tap {@!command[]}", 'quitting']; $chan.fail($_) }
});
}
elsif nqp::istype($out, IO::Handle) && $out.DEFINITE {
diff --git a/src/core/Proc/Async.pm b/src/core/Proc/Async.pm
index 7d24050..c1f22b8 100644
--- a/src/core/Proc/Async.pm
+++ b/src/core/Proc/Async.pm
@@ -162,10 +162,10 @@ my class Proc::Async {
die "Can only bind an output IO::Pipe to stdin of a process"
unless $sup.DEFINITE;
$!w = True;
- $!ready_promise.then({
- $sup().tap: { self.write($_) },
- done => { self.close-stdin },
- quit => { self.close-stdin };
+ $!ready_promise := $!ready_promise.then({
+ $sup().tap: { dd ['bind-stdin', 'writing']; self.write($_) },
+ done => { dd ['bind-stdin', 'donning']; self.close-stdin },
+ quit => { dd ['bind-stdin', 'quitting']; self.close-stdin };
});
}
diff --git a/src/core/Rakudo/Internals.pm b/src/core/Rakudo/Internals.pm
index 38d26a9..2e31b10 100644
--- a/src/core/Rakudo/Internals.pm
+++ b/src/core/Rakudo/Internals.pm
@@ -510,6 +510,7 @@ my class Rakudo::Internals {
}
method process(Mu \seq, Mu \data, Mu \err) {
+ dd ['Supply Sequencer processing', [data, err] ];
$!lock.protect: {
if err {
&!on-error(err);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment