-
-
Save MasterDuke17/c18483f2d851760014042931779529b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for "9.sh".IO.lines.kv -> $i, $oneliner { | |
say "line $i: $oneliner"; | |
my $proc = Proc::Async.new: '/home/dan/p6/install/bin/perl6-m', '-e', $oneliner; | |
react { | |
whenever $proc.Supply { # chunks | |
say ‘output: ’, $_; | |
} | |
whenever $proc.start { | |
say ‘Proc finished: exitcode=’, .exitcode, ‘ signal=’, .signal; | |
done # gracefully jump from the react block | |
} | |
whenever signal(SIGTERM).merge: signal(SIGINT) { | |
once { | |
say ‘Signal received, asking the process to stop’; | |
$proc.kill; # sends SIGHUP, change appropriately | |
whenever signal($_).zip: Promise.in(2).Supply { | |
say ‘Kill it!’; | |
$proc.kill: SIGKILL | |
} | |
} | |
} | |
whenever Promise.in(20) { | |
say ‘Timeout. Asking the process to stop’; | |
$proc.kill; # sends SIGHUP, change appropriately | |
whenever Promise.in(2) { | |
say ‘Timeout. Forcing the process to stop’; | |
$proc.kill: SIGKILL | |
} | |
} | |
} | |
} | |
say ‘Program finished’; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment