Vscode-cpptools: Terminal pops up on every debugger run

Created on 18 Nov 2018  Â·  8Comments  Â·  Source: microsoft/vscode-cpptools

Type: Debugger

  • OS and Version: Linux 4.4.0 (Ubuntu 14.04)
  • VS Code Version: 1.28.2
  • C/C++ Extension Version: 0.20.1
  • Other extensions you installed (and if the issue persists after disabling them): problems persists with other extensions disabled.
  • A clear and concise description of what the bug is.

This is rather a question i think. The problem is: every time i start debugger a terminal window pops up somewhere on screen.

I think it started to happen after cpptools update, i can reproduce it on vscode 1.25.1, 1.26.1, 1.27.2 and 1.28.2, but i don't remember this being like this before.

I had "externalConsole": false for quite some time, or so i think, and this was spawning new external terminal window in background every time i started debugger, but this was OK because that terminal was closing itself. Now it starts internal terminal called "cppdbg: my launch config name" and this terminal pops up on every debugger run even if i hide panel with terminal.

I tried to set "externalConsole": true to revert to old behavior, but now it doesn't close external terminal and says "Press any key to continue..." in it. If i start debugger 10 times, then i have 10 terminal windows open. This reminds me of how QtCreator works with terminal and this is far from ideal to say the least. Terminal windows quickly clog desktop and i have to manually close every window or keep piling them up.

Closing terminal after every debugger run is also very distracting in both cases: internal and external terminals. If i leave internal terminal open - this doesn't help: i leave it open, hide panel or switch to another internal terminal, next time i start debugger, it pops up again.

"presentation": { "reveal": "never" }, like in tasks.json doesn't seem to work either. What am i missing? Is there a way i can configure terminal window to disappear completely or automatically close itself? Either will work, i think. As a matter of fact, i don't really need to see application output at all. I will be happy with either:

  1. Terminal window doesn't appear
  2. Terminal window closes itself
  3. Terminal window appears somewhere in background and does its thing, but doesn't pop up on screen and doesn't take focus and i don't have to clean up something after every debugger run

Am i asking this in the right place or is this something related to vscode itself and not cpptools in particular?

Thanks in advance.

To Reproduce

Steps to reproduce the behavior:

  1. Ctrl-Shift-P
  2. Debugger: Start Debugging (F11 by default i believe)
{
    "name": "XXX",
    "type": "cppdbg",
    "request": "launch",
    "program": "${workspaceFolder}/XXX",
    "args": [
             ...
    ],
    "stopAtEntry": false,
    "cwd": "${workspaceFolder}",
    "environment": [],
    "externalConsole": false,
    "MIMode": "gdb",
    "setupCommands": [
        {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true,
        }
    ],
},

Additional info: Debug: Start Without Debugging does this too.

Most helpful comment

Yeah, it was ported to vscode or something and that read -p lives there now. I even submitted PR with attempt to introduce an option to work this around: https://github.com/microsoft/vscode/pull/72080 but it didn't get any traction whatsoever.

vscode issue where this is tracked is https://github.com/microsoft/vscode/issues/63813 (also submitted by you).

All 8 comments

I was able to downgrade extension to 0.19.0 and in that version external terminal closes itself. I looked into binaries and i assume one of the problems is in:

IL_0045:  ldstr "--title {0} -x bash -c 'cd {1}; {2} {3} {4} {5} ; echo; read -p {6} -n1;'"

In Terminal::LaunchInTerminalLinux(). Is that possible to make this read -p part optional somehow? Or is it possible to let me manually configure how do i want to launch shell to something like xfce4-terminal -x bash -c, no? Am i asking too much?

On the other hand i do welcome usage of vscode's internal terminal from the very bottom of my heart, alas i couldn't find where it is used and why does it pops up on every run, and i'm not even sure if should be doing that. IL is kind of hard to comprehend. This isn't really open-source extension, is it?

Any suggestions on workaround for this would be welcome.

OK, i found source code: https://github.com/Microsoft/MIEngine/blob/29c6569861b2042c43f04d8d78b2566db2e2ef1f/src/OpenDebugAD7/OpenDebug/Terminal.cs

So this is upstream apparently. And to answer my own questions: read -p isn't optional, /usr/bin/gnome-terminal is hardcoded. I don't even know what to say, sorry for bothering you, i guess, and i wish you the best of luck in moving away from gnome terminal towards vscode's internal terminal.

Still, if anyone would be so kind to suggest a workaround for this, except holding on to previous extension version, this would be very appreciated.

I really would like the window to close on exit. Please work the the MIEngine team to find a solution to fix this. Thank you

This would also be useful for me. I keep getting large stacks of post-debug terminals hanging around demanding attention from me.

this worked for me in python, I guess it will work for you to?
https://gist.github.com/martinandersen3d/7d41888e6d23835af8d20ce0919ab799

This isn't bad, unfortunately it doesn't quite work when another internal terminal exists which is usually the case because build is also running in terminal. So that internal terminal stays open on screen and i have to press Ctrl+~ instead of any key which kind of defeats the purpose.

What would fix this is something like read -p </bin/true, but i can't find a way to send input into terminal.

Thanks for sharing anyway, interesting stuff, i didn't know about post debug task.

@alekseyt I asked MIEngine to fix this, they said it isn't in their code: https://github.com/microsoft/MIEngine/issues/807
https://github.com/microsoft/MIEngine/issues/807#issuecomment-441785623

Yeah, it was ported to vscode or something and that read -p lives there now. I even submitted PR with attempt to introduce an option to work this around: https://github.com/microsoft/vscode/pull/72080 but it didn't get any traction whatsoever.

vscode issue where this is tracked is https://github.com/microsoft/vscode/issues/63813 (also submitted by you).

Was this page helpful?
0 / 5 - 0 ratings