Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Suppose I run cmd.exe and ping localhost. After that I ping localhost again but I click into the window and the ping stops until I press enter.

What happens exactly when I click into the window? Does it suspend the process or something else? I attached a screenshot to clarify this issue.

Note: I do not actually click but drag using the mouse which creates a white box in the window as you can see on the screenshot.

Edit: further clarification: What I really wish to know is whether dragging the window halts the cmd process or not?

Edit: even more clarification: I know that I'm using Quick Edit and pressing enter copies the contents I selected. What I do not know is what happens in the background.

enter image description here

share|improve this question
add comment

5 Answers

up vote 13 down vote accepted

When you select some text in the cmd.exe window, the process will carry on in the background until the next time it writes to Standard Output (or STDOUT, the data stream which is shown in the cmd.exe window).

When you exit the selection mode, the process will resume as normal.

You can test this by typing ping www.google.com -t into your cmd.exe window, and selecting some area of the output. You'll see it pause, and when you deselect the output will resume.

Edit: As per Fran's comment, you can use a tool such as Wireshark to see that activity does still happen after the point when you made the selection, and then stops.

share|improve this answer
1  
That alone doesn't test it. You also need to run Wireshark and see if the ICMP packets stop getting sent. If so, you are right that the process is suspended. If not, the process is not suspended, and the output simply gets buffered (until the buffers fill up, then it will either be suspended or data will be lost). –  Fran Aug 9 '12 at 17:27
    
I'm fairly sure @Fran is right - doesn't a whole bunch of output appear at once, if you waited long enough in selection mode? –  Izkata Aug 9 '12 at 18:31
    
@Fran It's sufficient to detect that the process is paused at some point. I'll add your suggestion to the answer –  JohnL Aug 9 '12 at 18:41
add comment

Once you click into the Command Prompt window, the console host will no longer allow output to be written. The application itself keeps running, but nothing is written to the screen.

Of course, as long as there is only a single thread, this is basically the same thing as having your process frozen. As the single thread tries to write some output before doing more work.

If I run ping -t localhost and click into the command prompt window, I can then inspect the call stack of the main ping.exe thread with Process Explorer.

enter image description here

We can see that ping.exe tried to write some output. It called write() in the C runtime library. That function, at some point, calls GetConsoleMode. As it seems, that function will check if the user is currently in mark mode and block execution if needed.

Further Analysis

We can further proof this behavior by examining the behavior of ping with Wireshark

When running ping -t superuser.com we see the following output in Wireshark:
enter image description here

Now, let's mark a box in the command prompt.
enter image description here
Suddenly, no more pings are logged in Wireshark. ping is no longer sending any packets.

But we already knew that...

Right, let's see if the output is actually the issue here! Let's direct the output to the NUL device:

enter image description here

Now, there is no longer any ouput. We can now mark text in the box all day long, packets will be logged in Wireshark.

enter image description here

share|improve this answer
    
Thanks for the stack trace. –  Adam Arold Aug 9 '12 at 21:04
    
If I hadn't +1'd already for the original answer, I'd +1 now for the "Further analysis" –  JohnL Aug 14 '12 at 21:44
add comment

That is because the window has entered Mark mode. When you press enter, it copies the selected text to the clipboard. To my knowledge, there is no setting for this, so I'm not sure why it's doing that when you just click into the window. Normally you have to right click and hit "Mark". Check to make sure no keys are stuck on your keyboard.

share|improve this answer
    
And what does "Mark mode" do? Does it suspend the process? –  Adam Arold Aug 9 '12 at 16:33
    
Mark mode is used for copying text from the command window. AFAIK that is the only use, though I suppose there may be others. –  Garrett Aug 9 '12 at 16:36
3  
The setting is called Quick Edit Mode. Click the icon in the top left hand corner, choose Properties and Choose Quick Edit Mode on the Options tab. From what I know, the process will continue in the background until it needs to interact with the console, at which point it will block –  JohnL Aug 9 '12 at 16:37
    
@JohnL please create an answer because your comment is what I'm looking for. –  Adam Arold Aug 9 '12 at 16:41
    
@edem Added an answer :) –  JohnL Aug 9 '12 at 16:58
add comment

When you are selecting the text to copy from the window (when in Mark mode) the system suspends the current process in that window.

Example batch file:

:test
echo %0
goto test

when this is run, as soon as I mark the area to copy, the screen stops scrolling

share|improve this answer
    
I was about to post the exact same thing (except that my batch file was echo blah↵%0). :-) –  Synetech Aug 9 '12 at 21:04
add comment

Your CMD windows is in quick edit mode which automatically enter the edit mode when you click on the screen. The Enter is for copy the text in the white-box and exit the edit mode.

Normally CMD only enter edit mode when you right click on the black screen and choose Mark.

To change back to normal, right click on the title bar of the windows and choose Properties, select Options tab and deselect "Quick Edit Mode" and click ok.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.