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
{{ message }}
Repository navigation
Failed to open /dev/tty with vscode debugger #3351
In my program, I tried to read /dev/tty. The program cannot open the file with vscode debugger, but the file is successfully opened with gdb command line.
The source code is:
#include<stdio.h>
#include<fcntl.h>intmain(int argc, charconst *argv[])
{
int f = open("/dev/tty", O_RDONLY);
printf("open tty %d\n",f);
return0;
}
The program is then build with g++ -g ./main.cpp.
When I use gdb to debug in vscode, it gives:
open tty -1
However, with command line gdb ./a.out, the file can be open successfully.
(gdb) r
Starting program: /home/miki0w0/c_test/a.out
open tty 3
[Inferior 1 (process 22818) exited normally]
(gdb) q
Can you add errno to your printf statement to see what the actual error is? I wonder if it is a permissions issue but would need to know more about why its failing.
Can you add errno to your printf statement to see what the actual error is? I wonder if it is a permissions issue but would need to know more about why its failing.
I have the same issue, but with opening regular file for writing. Debugging with GDB from command line works well.
Errno code is "No such file or directory".
I use Ubuntu 18.04
I had the same issue. The reason was the program was not running within a terminal but rather the debug console.
FIxed it by setting "console": "integratedTerminal" in launch config.
Reacted by Pablo Díaz-López, drcharris, Ryan Melendez, Martin Bjeldbak Madsen, EMRE ÇELİK, Tom Jennings, Nathan FG, Max, dc, Sébastien Allamand and 15 more
Reacted by Nathan FG, Sébastien Allamand, Tony, Kanuuki, Léandre Daumont, Jonny Polite, Thiago Coimbra Lemos, Daniel Ferreira and Sam Laister
Reacted by Nathan FG, Sébastien Allamand, Kanuuki, virtuallyunknown, Liam Neville, MilindVaidya03, Léandre Daumont, Bryan, Thiago Coimbra Lemos, Daniel Ferreira and 2 more
Reacted by Léandre Daumont, Thiago Coimbra Lemos and Daniel Ferreira
Activity
[-]Failed to open /dev/tty with vscode debug [/-][+]Failed to open /dev/tty with vscode debugger[/+]pieandcakes commentedon May 2, 2019
Can you add
errnoto your printf statement to see what the actual error is? I wonder if it is a permissions issue but would need to know more about why its failing.For reference: http://man7.org/linux/man-pages/man3/errno.3.html
0w0miki commentedon May 3, 2019
I added
errnoto the code, and the following are the results with VS code debugger and gdb command line.Using debugger, the output is:
Using
gdb ./a.out, the output is:The code is modified as
osa1 commentedon Sep 16, 2019
Just came here to report this -- would be good to see this fixed as this makes debugging TUI apps in vscode quite hard.
gerekon commentedon Oct 11, 2019
I have the same issue, but with opening regular file for writing. Debugging with GDB from command line works well.
Errno code is "No such file or directory".
I use Ubuntu 18.04
remicorniere commentedon Dec 22, 2019
Came here to report the same thing. It makes TUI apps impossible to debug.
gnojus commentedon Feb 8, 2020
Same issue (with GO debugger)
goto3k commentedon Apr 28, 2020
Having the same issue:
fd = open("/dev/tty", O_RDWR, 0);fd=-1
errno=6 (No such device or address),
pieandcakes commentedon Apr 28, 2020
Andrew Wang (@WardenGnaw)
github-actions commentedon Dec 9, 2020
This issue has been closed automatically because it needs more information and has not had recent activity.
MisterMX commentedon Mar 19, 2022
I had the same issue. The reason was the program was not running within a terminal but rather the debug console.
FIxed it by setting
"console": "integratedTerminal"in launch config.totszwai commentedon Feb 8, 2023
Max (@MisterMX) your solution no longer exists/work in the latest VSCode, do you know what's the new alternative?
Pierson Lee (@pieandcakes) Andrew Wang (@WardenGnaw) Can we re-open this?
mbenson commentedon Jan 18, 2024
"console": "integratedTerminal"solution WFM so fartalraveh1 commentedon Dec 17, 2024
Same problem here.
Workaround "console": "integratedTerminal" no longer supported.
Is there any other workaround?
dan-frohlich commentedon Apr 3, 2025
I added this and it got the debugger working. My app expects to be running in a "terminal" or
TTYI'm running
vscode:1.98.2onubuntu"console": "integratedTerminal"