Skip to content

Instantly share code, notes, and snippets.

@awwaiid
Created August 26, 2016 05:56
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 awwaiid/7f1c6819ec00a0cc8f8bdb3de14e2ab3 to your computer and use it in GitHub Desktop.
Save awwaiid/7f1c6819ec00a0cc8f8bdb3de14e2ab3 to your computer and use it in GitHub Desktop.
# signal(SIGINT).tap: {
# note "Took { now - INIT now } seconds. $*THREAD";
# }
my $interrupt = signal(SIGINT);
$interrupt.tap: -> $v {
note "[got interrupt $v]";
}
my $interrupt_text = $interrupt.map: -> $v {
# note "Took { now - INIT now } seconds. $*THREAD";
note "Got SIGINT";
# "SIGINT\n";
$v
}
my $input = $*IN.Supply(size => 1);
# my $input = $*IN.Supply;
my $merged_input = $input.merge($interrupt_text);
# my $merged_input = $interrupt_text.merge($input);
# loop {
react {
whenever $interrupt -> $txt {
# whenever $merged_input -> $txt {
# whenever $interrupt_text.lines -> $txt {
say "interrupt: [$txt]";
# say "interrupt: $interrupt";
# exit if $txt ~~ /SIGINT/;
}
whenever $input -> $txt {
# whenever $merged_input -> $txt {
# whenever $interrupt_text.lines -> $txt {
say "input: [$txt]";
# say "interrupt: $interrupt";
# exit if $txt ~~ /SIGINT/;
}
}
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment