Discussion:
Bug?: Ctrl-C causes PowerShell to Exit
(too old to reply)
JimF
2006-10-16 18:46:02 UTC
Permalink
I am not sure if there is a more appropriate group or place to post potential
bugs, so I will drop this off here.

I have found a consistent way of getting PowerShell to exit abnormally (at
least on my Windows 2003 R2 computer).

At a prompt, type "ping -t <some address>"; It doesn't even have to be a
valid address. For those unfamiliar with the -t parameter it basically does
not stop pinging until you do a Ctrl-C.

If you simply let it run and type Ctrl-C, everything works as expected--BUT
a feature of using -t is you can also use Ctrl-Break to get intermediate
statistics and continue.

If you do at least one Ctrl-Break, and then finally do a Ctrl-C, PowerShell
will exit after the Ctrl-C.

Also, after you do the first Ctrl-Break you will see a message "Ctrl-Break
typed; exiting", presumably from PowerShell since I don’t see this “extra”
message in cmd.exe.

Thanks,
Jim
dreeschkind
2006-10-16 21:19:01 UTC
Permalink
Post by JimF
I am not sure if there is a more appropriate group or place to post potential
bugs, so I will drop this off here.
PowerShell has it's own newsgroup: microsoft.public.windows.powershell

http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?&guid=&sloc=en-us&dg=microsoft.public.windows.powershell

If you own a Windows Live ID (hotmail.com / Passport account) you can also
file bugs and suggestions on http://connect.microsoft.com
Post by JimF
I have found a consistent way of getting PowerShell to exit abnormally (at
least on my Windows 2003 R2 computer).
This behavior is by design and not considered "abnormally", but it has been
critized before.
Post by JimF
If you do at least one Ctrl-Break, and then finally do a Ctrl-C, PowerShell
will exit after the Ctrl-C.
Also, after you do the first Ctrl-Break you will see a message "Ctrl-Break
typed; exiting", presumably from PowerShell since I don’t see this “extra”
message in cmd.exe.
This message is indeed from PowerShell. You'll also get it by typing
Ctrl-Break directly at the PowerShell prompt.
Actually, PowerShell seems to quit right after you hit Ctrl-Break the first
time.
The console window in the Taskbar is still called PowerShell, but PowerShell
won't be listed in Task-Manager at this point of time. The console window now
belongs to ping.exe. This is confusing, but I guess it is an issue of the
console subsystem of Windows.

If you wan't this behavior to change, I recommend logging into the following
connect site and voting for this issue to be fixed. You should also leave a
comment there mentioning that this is conflicting with the -t parameter of
ping.exe

https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=180072&SiteID=99

There are also various other ways of getting ping statistics using
PowerShell. Have a look at the PowerShell newsgroup, there is currently an
active thread on that topic.

--
greetings
dreeschkind
JimF
2006-10-17 12:47:02 UTC
Permalink
Post by dreeschkind
Post by JimF
I am not sure if there is a more appropriate group or place to post potential
bugs, so I will drop this off here.
PowerShell has it's own newsgroup: microsoft.public.windows.powershell
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?&guid=&sloc=en-us&dg=microsoft.public.windows.powershell
If you own a Windows Live ID (hotmail.com / Passport account) you can also
file bugs and suggestions on http://connect.microsoft.com
Post by JimF
I have found a consistent way of getting PowerShell to exit abnormally (at
least on my Windows 2003 R2 computer).
This behavior is by design and not considered "abnormally", but it has been
critized before.
Post by JimF
If you do at least one Ctrl-Break, and then finally do a Ctrl-C, PowerShell
will exit after the Ctrl-C.
Also, after you do the first Ctrl-Break you will see a message "Ctrl-Break
typed; exiting", presumably from PowerShell since I don’t see this “extra”
message in cmd.exe.
This message is indeed from PowerShell. You'll also get it by typing
Ctrl-Break directly at the PowerShell prompt.
Actually, PowerShell seems to quit right after you hit Ctrl-Break the first
time.
The console window in the Taskbar is still called PowerShell, but PowerShell
won't be listed in Task-Manager at this point of time. The console window now
belongs to ping.exe. This is confusing, but I guess it is an issue of the
console subsystem of Windows.
If you wan't this behavior to change, I recommend logging into the following
connect site and voting for this issue to be fixed. You should also leave a
comment there mentioning that this is conflicting with the -t parameter of
ping.exe
https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=180072&SiteID=99
There are also various other ways of getting ping statistics using
PowerShell. Have a look at the PowerShell newsgroup, there is currently an
active thread on that topic.
--
greetings
dreeschkind
JimF
2006-10-17 18:45:01 UTC
Permalink
Hmm, not sure what happened to my last post… but…

Thanks for the reply. I will start looking for answers and info in the
PowerShell group.

I am not part of the community that you mentioned, so I can’t vote on the
functionality, BUT I do now understand what is going on and why the current
PowerShell must exit (from what I know of PowerShell). After you told me that
PowerShell will exit after doing a Ctrl-Break on the command line without
running a program I realized what was happening. PowerShell is based upon
Framework 2.0 and 2.0 allows for Ctrl-C and Ctrl-Break handling. With a
Ctrl-C, you can tell the framework, “Thanks for letting me know, but ignore
it”. You can’t tell the framework to “ignore” a Ctrl-Break. If you do, the
framework will throw an exception and kill your process to “spite” you.

So, for them to ignore the Ctrl-Break either the Framework would have to be
modified or they PowerShell team would have to resort to other tactics, such
as using native code somewhere instead.

You also mentioned other ways of getting the ping stats. I did a search in
the PowerShell group using the link you gave me, but it only returned one
thread and it only mentioned link in the context of a sample (get-command
ping). Of the other PowerShell samples that I have seen, they seem very
verbose for the information I am interested in—typically I am just trying to
find the IP or I use -t to verify when a server is back up from a reboot.

Thanks again,
Jim
dreeschkind
2006-10-17 19:48:01 UTC
Permalink
Post by JimF
I am not part of the community that you mentioned, so I can’t vote on the
functionality
As I mentioned, all you need is a (free) Microsoft Passport (or hotmail.com)
account (now called Windows Live ID). You should be able to register on that
site, but of course you don't have to if you don't want to. ;-)
Post by JimF
BUT I do now understand what is going on and why the current
PowerShell must exit (from what I know of PowerShell).
One member of the PowerShell team explained why they designed it that way:

"Ctrl-C gently terminates the current pipeline, whereas Ctrl-Break allows the
user to forcefully terminate the session. This distinction is important
because PowerShell commands respect the gentle Ctrl-C signal, but some
applications / .Net API calls do not. The alternative would be to have
Ctrl-C forcefully terminate the pipeline, but that could risk data loss and
system stability."

http://groups.google.de/group/microsoft.public.windows.powershell/tree/browse_frm/thread/178c6310b9b40294/c051e7d296799250?rnum=11&_done=%2Fgroup%2Fmicrosoft.public.windows.powershell%2Fbrowse_frm%2Fthread%2F178c6310b9b40294%2F7f57197ca9693000%3Ftvc%3D1%26#doc_8561430906420c8f
Post by JimF
You also mentioned other ways of getting the ping stats. I did a search in
the PowerShell group using the link you gave me, but it only returned one
thread and it only mentioned link in the context of a sample (get-command
ping).
This is the thread that I was talking about:

http://groups.google.de/group/microsoft.public.windows.powershell/browse_frm/thread/1cab7dd0b93b96b8/562fd2ed9c7e9570?hl=de#562fd2ed9c7e9570
Post by JimF
Of the other PowerShell samples that I have seen, they seem very
verbose for the information I am interested in—typically I am just trying to
find the IP or I use -t to verify when a server is back up from a reboot.
The great thing is that PowerShell can be verbose _and_ pithy! All you need
to do is using some (standard) aliases or write a little function (often a
one-liner) and you'll be able to get similar functionality as ping -t without
much typing.

--
greetings
dreeschkind
JimF
2006-10-18 13:00:02 UTC
Permalink
Again, thanks for the info. But...
Post by dreeschkind
As I mentioned, all you need is a (free) Microsoft Passport (or hotmail.com)
account (now called Windows Live ID). You should be able to register on that
site, but of course you don't have to if you don't want to. ;-)
No, I am not allowed to register. It appears that this communitiy is now
closed to new participation. I have tried differnt ways of getting to it.
Your link, for example, simply tells me that I am not authorized. When I look
at the "Available Connections" page, PowerShell is not even listed.

But thanks anyway.

Jim

Loading...