Skip to content

Instantly share code, notes, and snippets.

@ugexe

ugexe/procs.pl6 Secret

Last active June 17, 2017 19:48
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 ugexe/118f826fa96ec131b711d23762dd1df6 to your computer and use it in GitHub Desktop.
Save ugexe/118f826fa96ec131b711d23762dd1df6 to your computer and use it in GitHub Desktop.
Proc input size not matching output size?
my $proc = run «cat -», :in, :out, :bin;
say "started";
my $input = ("a" x 1000000).encode;
say "input total: {$input.bytes}";
my $promise = start {
$proc.in.write: $input;
say "input written";
$proc.in.close;
say "input closed";
}
my $total;
$proc.out.Supply.act: {say "Got {.bytes} bytes"; $total += .bytes}
await $promise;
$proc.out.close;
say "Bytes received: $total";
say "Exit code: {$proc.exitcode}";
@ugexe
Copy link
Author

ugexe commented Jun 17, 2017

nickl@li685-90:~/perl6$ perl6 procs.pl6
started
input total: 1000000
Got 65536 bytes
Got 65536 bytes
Got 65536 bytes
Got 22656 bytes
Got 65536 bytes
Got 65536 bytes
Got 65536 bytes
Got 44096 bytes
Got 65536 bytes
Got 65536 bytes
Got 65536 bytes
Got 1216 bytes
Got 65536 bytes
Got 65536 bytes
input written
Got 65536 bytes
Got 22656 bytes
Got 65536 bytes
Got 57408 bytes
input closed
Bytes received: 1000000
Exit code: 0
nickl@li685-90:~/perl6$ perl6 procs.pl6
started
input total: 1000000
Got 65536 bytes
input written
Got 65536 bytes
Got 65536 bytes
Got 65536 bytes
input closed
Bytes received: 262144
Exit code: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment