Skip to content

Instantly share code, notes, and snippets.

@zachbonham
Created February 19, 2013 00:57
Show Gist options
  • Save zachbonham/4982148 to your computer and use it in GitHub Desktop.
Save zachbonham/4982148 to your computer and use it in GitHub Desktop.
foreman prototype in powershell. Mainly the CTRL+C break for powershell.
$arg1 = "hello1"
$arg2 = "hello2"
$p = $(start-process -filepath .\bin\debug\hello.exe -argumentlist $arg1 -nonewwindow -passthru; start-process -filepath .\bin\debug\hello.exe -argumentlist $arg2 -nonewwindow -passthru);
#$p | wait-process
[console]::TreatControlCAsInput = $true
while($true)
{
if ( [console]::KeyAvailable )
{
$key = [system.console]::readkey($true)
if(($key.modifiers -band [consolemodifiers]"control") -and ($key.key -eq "C"))
{
"shutting down"
$p | % { $_.Kill() }
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment