Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Why the Strange Behavior in Attached Conhost Session

Jun
1,092
48
The following strange thing is happening, and I'm not sure whether it is normal or a bug.

From a TCC session in TCMD, I open a legacy standalone TCC session (start /pgm C:\Windows\System32\conhost.exe ...\tcc.exe). It opens and runs fine. Now I attach that session. When I try to enter a command, I get a strange display.

Code:
[TCC36.50.71 (56352) C:\]
->←[30;3H←[0;96;40me←[0;37;40m

What I type appears as a left-facing arrow with what I assume is some ANSI sequences after it. As I continue to type, additional left arrows appear and the ANSI stuff shifts to the right.

If I press ENTER, I get a new prompt, and everything works fine after that. The strange behavior happens only right after I attach the session. My prompt variable does not contain any of the extraneous stuff that appears initially.
 
That's ANSI-speak for cursor to column 30, line 3, then normal colors (0), bright cyan(96) on black (40), then the letter 'e', then normal colors (0), white (37) on black (40). Do those bear any relationship to your prompt? I have a colored prompt but when I tried your experiment it worked fine.

The left arrow is the escape character (ascii 27), and "<Esc>]" is known as "CSI" (control sequence initiator).
 
Oh, I see. You must start typing to see that stuff (I typed 'e'). After attaching the console I saw this (the escapes don't show; for me they were empty boxes).

Code:
[1;6H[0;93;49me[0;37;40m

That's a lot like yours but the middle one is normal, bright yellow on default which are precisely my input colors.

And I had the cursor one wrong; it's CSI row ; column H (not column ; row).
 
Bright cyan on black is the color configured for command-line input.

It looks as though ANSI sequences are not being processed initially. Once a new command prompt has been generated, things work properly. So it seems that something is not right when the session gets attached and imported into a Take Command tab window.

Can you suggest any way I could test this further?
 
But that leaves an interesting question. Below is what I see. The console is obviously in VT mode because I have the correct green prompt. So I wonder why it doesn't recognize the sequences that follow.

1783445944253.webp
 
I think I was wrong about that. The green prompt was in the console before it was attached. I did this little test. My 4UTILS plugin has a function ENABLEVT which adds the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag to the console output mode. If I do delay 10 & enablevt in a console and attach it during the delay then all is OK after it's attached; that is, there are no control sequences mixed in with the input. For some reason, unknown to me, ENABLE_VIRTUAL_TERMINAL_PROCESSING is lost when a console is attached. That ought to be easy for Rex to fix.
 
Back
Top