Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

manually breaking out of an infinite loop?

2,770 views
Skip to first unread message

James

unread,
Mar 31, 2009, 11:59:40 AM3/31/09
to
hello,

new to PS and playing around... I mistakenly creating and executed an
infinite loop while working interactively with the shell... ctrl+c and
ctrl+z didn't work to kill it, ctrl+break killed the whole shell session...
is there a way to just manually kill the currently executing command without
terminating the whole shell session?

Marco Shaw [MVP]

unread,
Mar 31, 2009, 12:12:21 PM3/31/09
to

Ctrl-C should work in most circumstances. It is possible that
powershell.exe got so wrapped up in what it was executing that it was
ignoring the signal to stop. Perhaps waiting a bit longer might have
worked?

Marco

--
*Microsoft MVP - Windows PowerShell
https://mvp.support.microsoft.com/profile/Marco.Shaw
*Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com

James

unread,
Mar 31, 2009, 12:15:16 PM3/31/09
to
ok... I thought ctrl+c was it... I guess an infinite loop may be to taxing
as you said. Thanks for the reply, I appreciate it.

"Marco Shaw [MVP]" <marco.shaw@NO_SPAMgmail.com> wrote in message
news:uLDw6th...@TK2MSFTNGP06.phx.gbl...

Josh Einstein

unread,
Mar 31, 2009, 12:33:32 PM3/31/09
to
Depends on where the loop is. Unless the command is yielding back to
PowerShell, it might never see the stop signal. There is a property that
compiled commands can check to ask PowerShell if it should quit and also if
a command tries to write something to the pipeline after PowerShell has
stopped the pipeline, an exception will be thrown which usually ends the
command.

Because of the way PowerShell executes scripts though, I don't think it's
possible to hang in a script unless the script was stuck calling something
external.

Josh

"James" <no...@nowhere.com> wrote in message
news:#oxi$vhsJH...@TK2MSFTNGP03.phx.gbl...

0 new messages