You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ConEmu build: 170305 x64
OS version: W7 x64s 7 x64
Used shell version: cmd, ipython3 5.2.2
Summary
The ConEmuANSI variable is set to ON in a non-ConEmu console spawned from ConEmu, and if it's set in a process that doesn't have the ConEmu hook DLL in it, the color escapes are visible. ConEmu sometimes intervenes and sets ConEmuANSI to OFF, but it doesn't do that in a couple of situations.
Problem description
When I start a process inside ConEmu, with the default settings, ConEmu sets the ConEmuANSI environment variable to ON. This makes sense, because ConEmu has a hook DLL that adds ANSI escape sequence support.
If I spawn a child process in a new console, the hook DLL tends to stop being injected, and ConEmu sometimes sets ConEmuANSI to OFF.
To install ipython3
(I haven't tested this, but I think this is correct.)
Install Python3 somewhere
Run <install-dir>\Scripts\pip.exe install ipython
Scenario 1: using start cmd
Reset settings to default
Use the default {Shells} > {cmd} task.
Run start cmd in the shell
A new non-ConEmu console window appears with a cmd.exe shell in it.
The cmd.exe prompt is colored in this shell, indicating that the hook DLL is present.
In the new shell, the ConEmuANSI variable is OFF, but ConEmuHooks is Enabled.
In the new shell, run cmd
Now the cmd prompt's escapes are visible. ConEmuANSI is still OFF and ConEmuHooks is still Enabled.
Run ipython3. The prompt is colored.
Examine the process tree in sysinternals Process Explorer. Starting with python.exe, I see this ancestry:
ConEmuC64.exe
cmd.exe (the original shell) - ConEmuHk64.dll is present
cmd.exe (the start cmd shell) - ConEmuHk64.dll is present
cmd.exe (the final cmd shell) - ConEmuHk64.dll is not present
ipython.exe - ConEmuHk64.dll is not present
python.exe - ConEmuHk64.dll is not present
It's curious that the start cmd shell has the hook, but its child doesn't.
Scenario 2: using start -new_console:z cmd
Reset settings to default
Use the default {Shells} > {cmd} task.
Run start -new_console:z cmd in the shell
A new non-ConEmu console window appears with a cmd.exe shell in it.
The cmd.exe prompt's escape sequences are visible, indicating the hook DLL is not present.
In the new shell, the ConEmuANSI variable is ON, and ConEmuHooks is Enabled.
Run ipython3. The REPL prints many escape sequences, probably because prompt_toolkit thinks ConEmu ANSI support is enabled.
The ConEmuANSI variable is set to ON, and ConEmuHooks is Enabled.
Run ipython. As with scenario 2, the escape sequences are visible.
Examine the process tree in sysinternals Process Explorer. I see these important processes:
ConEmuC64.exe
conemu-cyg-64.exe - ConEmuHk64.dll is present
winpty.exe - ConEmuHk64.dll is present
winpty-agent.exe - ConEmuHk64.dll is not present
cmd.exe - ConEmuHk64.dll is not present
ipython.exe - ConEmuHk64.dll is not present
python.exe - ConEmuHk64.dll is not present
winpty.exe starts its winpty-agent.exe child process in a new, hidden console, which resembles scenarios 1 and 2. ConEmu does not install the hook DLL into the winpty-agent.exe child, but it also leaves ConEmuANSI set to ON, which then confuses ipython3. I could make winpty.exe clear ConEmuANSI, but:
ConEmu was responsible for setting the variable, and
ConEmu sometimes sets ConEmuAnsi back to OFF when a new console is spawned
I think ConEmu should set the variable to OFF in all three scenarios.
The text was updated successfully, but these errors were encountered:
rprichard
changed the title
ConEmu leaves ConEmuANSI set to ON when a process spawns a child process
ConEmu leaves ConEmuANSI set to ON when a process spawns a child process in a new console
Mar 16, 2017
This issue could be responsible for this VSCode issue (microsoft/vscode#22616). If I start VSCode from ConEmu (e.g. by running Code.exe), then:
ConEmu does not hook the VSCode processes
The ConEmuANSI variable is set to ON in the VSCode processes.
When VSCode starts its integrated terminal, it uses winpty to create a hidden console (a non-ConEmu "RealConsole").
winpty, unlike ConEmu, does not hook WriteConsole et al to add VT/100 color escape support.
PHP-based components see that ConEmuANSI is set and write escapes, which are visible to the user.
A major caveat: I don't know if this scenario is the one causing the VSCode issue, and it might not be. It doesn't really matter, though, because I've reproduced it myself.
I'm probably going to end up filtering out ConEmuANSI in winpty, but I still think this is a ConEmu bug.
Versions
ConEmu build: 170305 x64
OS version: W7 x64s 7 x64
Used shell version: cmd, ipython3 5.2.2
Summary
The
ConEmuANSI
variable is set toON
in a non-ConEmu console spawned from ConEmu, and if it's set in a process that doesn't have the ConEmu hook DLL in it, the color escapes are visible. ConEmu sometimes intervenes and setsConEmuANSI
toOFF
, but it doesn't do that in a couple of situations.Problem description
When I start a process inside ConEmu, with the default settings, ConEmu sets the
ConEmuANSI
environment variable toON
. This makes sense, because ConEmu has a hook DLL that adds ANSI escape sequence support.If I spawn a child process in a new console, the hook DLL tends to stop being injected, and ConEmu sometimes sets
ConEmuANSI
toOFF
.To install ipython3
(I haven't tested this, but I think this is correct.)
<install-dir>\Scripts\pip.exe install ipython
Scenario 1: using
start cmd
{Shells} > {cmd}
task.start cmd
in the shellConEmuANSI
variable isOFF
, butConEmuHooks
isEnabled
.cmd
ConEmuANSI
is stillOFF
andConEmuHooks
is stillEnabled
.python.exe
, I see this ancestry:ConEmuC64.exe
start cmd
shell) - ConEmuHk64.dll is presentIt's curious that the
start cmd
shell has the hook, but its child doesn't.Scenario 2: using
start -new_console:z cmd
{Shells} > {cmd}
task.start -new_console:z cmd
in the shellConEmuANSI
variable isON
, andConEmuHooks
isEnabled
.prompt_toolkit
thinks ConEmu ANSI support is enabled.Scenario 3: using winpty with ipython3
This is possibly winpty issue rprichard/winpty#102.
C:\cygwin64\bin
. Install winpty 0.4.2 from https://github.com/rprichard/winpty/releases/tag/0.4.2.C:\cygwin64\bin\conemu-cyg-64.exe
.winpty cmd
ConEmuANSI
variable is set toON
, andConEmuHooks
isEnabled
.ConEmuC64.exe
winpty.exe - ConEmuHk64.dll is present
winpty.exe
starts itswinpty-agent.exe
child process in a new, hidden console, which resembles scenarios 1 and 2. ConEmu does not install the hook DLL into the winpty-agent.exe child, but it also leavesConEmuANSI
set toON
, which then confuses ipython3. I could makewinpty.exe
clearConEmuANSI
, but:ConEmuAnsi
back toOFF
when a new console is spawnedI think ConEmu should set the variable to
OFF
in all three scenarios.The text was updated successfully, but these errors were encountered: