Skip to content

Instantly share code, notes, and snippets.

@b2gills

b2gills/eof.p6 Secret

Last active November 4, 2017 18:26
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 b2gills/354aed9849d8a0f5fc537882f28f896c to your computer and use it in GitHub Desktop.
Save b2gills/354aed9849d8a0f5fc537882f28f896c to your computer and use it in GitHub Desktop.
Test eof
#! /usr/bin/env perl6
use v6.d.PREVIEW;
my $proc = Proc::Async.new(
:w,
$*EXECUTABLE,
'-e',
'loop { last if $*IN.eof; put "Got line " ~ $*IN.get }'
);
start {
await $proc.ready;
$proc.put: 'a';
sleep .5;
$proc.put: 'b';
sleep .5;
$proc.put: 'c';
sleep .5;
$proc.close-stdin;
}
start react {
whenever $proc.stdout.lines {
say ':', $_
}
whenever $proc.stderr {}
}
say 'exitcode ',$proc.start.result.exitcode;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment