# New Ticket Created by Sam S.
# Please include the string: [perl #129882]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=129882 >
The following code attempts to pipe a large Blob (larger than a pipe's
buffer size) through an external command.
However, it hangs on the `.in.close` line and never finishes:
my $proc = run «cat -», :in, :out, :bin;
my $input = ("a" x 100).encode;
my $promise = start {
$proc.in.write: $input;
$proc.in.close;
}
say $proc.out.slurp-rest(:close, :bin).bytes;
await $promise;
More verbose version of the code with debug output showing where it blocks:
https://gist.github.com/smls/75518c746ca65b3287482c491971eac0
IRC comments:
moar sometimes gets confused, i think
or maybe it's libuv
shouldn't that give an error as other handles across threads do?
you get the same behaviour with
https://rt.perl.org/Public/Bug/Display.html?id=129787
Note that without the `start` (i.e. when writing to `.in` and then
reading from `.out` in the same thread), it already hangs on the
`.in.write`, as geekosaur explains:
it will block if the process is not reading, yes. pipes have
finite buffer space
whether this block is happening at OS level or if libuv is
supposed to be using non-blocking operations and return a "would
block, try again" and some higher level is blocking based on
that, I cannot say