-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Every integrated terminal opens one more fd pointing to /dev/ptmx or /dev/pts/ptmx #710
Comments
I find there is an easier way to reproduce this. Just type the following command in each terminal (open a few terminals before doing this): file /proc/$$/fd/* | grep -v 'No such file' Every terminal shows a different count of The first terminal (1 fd -> /dev/urandom): /proc/29722/fd/0: symbolic link to /dev/pts/4
/proc/29722/fd/1: symbolic link to /dev/pts/4
/proc/29722/fd/19: symbolic link to /dev/urandom
/proc/29722/fd/2: symbolic link to /dev/pts/4
/proc/29722/fd/20: symbolic link to /home/USER/.vscode-server/data/logs/20240902T140816/ptyhost.log
/proc/29722/fd/21: symbolic link to /home/USER/.vscode-server/data/logs/20240902T140816/network.log
/proc/29722/fd/24: symbolic link to /home/USER/.vscode-server/data/logs/20240902T140816/remoteagent.log
/proc/29722/fd/255: symbolic link to /dev/pts/4 The second terminal (1 fd -> /dev/urandom and 1 fd -> /dev/ptmx): /proc/29831/fd/0: symbolic link to /dev/pts/5
/proc/29831/fd/1: symbolic link to /dev/pts/5
/proc/29831/fd/19: symbolic link to /dev/urandom
/proc/29831/fd/2: symbolic link to /dev/pts/5
/proc/29831/fd/20: symbolic link to /home/USER/.vscode-server/data/logs/20240902T140816/ptyhost.log
/proc/29831/fd/21: symbolic link to /home/USER/.vscode-server/data/logs/20240902T140816/network.log
/proc/29831/fd/22: symbolic link to /dev/ptmx
/proc/29831/fd/24: symbolic link to /home/USER/.vscode-server/data/logs/20240902T140816/remoteagent.log
/proc/29831/fd/255: symbolic link to /dev/pts/5 The third terminal (1 fd -> /dev/urandom and 2 fds -> /dev/ptmx): /proc/29893/fd/0: symbolic link to /dev/pts/6
/proc/29893/fd/1: symbolic link to /dev/pts/6
/proc/29893/fd/19: symbolic link to /dev/urandom
/proc/29893/fd/2: symbolic link to /dev/pts/6
/proc/29893/fd/20: symbolic link to /home/USER/.vscode-server/data/logs/20240902T140816/ptyhost.log
/proc/29893/fd/21: symbolic link to /home/USER/.vscode-server/data/logs/20240902T140816/network.log
/proc/29893/fd/22: symbolic link to /dev/ptmx
/proc/29893/fd/24: symbolic link to /home/USER/.vscode-server/data/logs/20240902T140816/remoteagent.log
/proc/29893/fd/25: symbolic link to /dev/ptmx
/proc/29893/fd/255: symbolic link to /dev/pts/6 I also did some research after posting the issue and now understand that /dev/ptmx is a pseudo-terminal master device and not needed by shells (which need slave devices). Maybe there is a missing |
AFAIK, that symbolic link creation, @Tyriar or @roblourens any thoughts here? |
The symbolic links come from Linux's /proc virtual filesystem (only Linux has it). This doesn't mean that VS Code creates any symbolic links, but means the shells (and their subprocesses) keep those files open when they're running. I only reproduced the issue in my WSL and a remote Linux server. I don't have a Linux desktop environment for now, but I will see if I can reproduce it on a virtual machine. |
The integrated terminal on a Linux desktop (inside a virtual machine) has the same problem. Here are some screenshots. The issue does not exist in external terminals on a Linux desktop. There's my .vscode/launch.json, it uses external terminals to launch the given Python file: {
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "externalTerminal"
}
]
} The contents of main.py: import os
assert 0 == os.system("file /proc/$$/fd/* | grep -v 'No such file'")
_ = input('Waiting for anything...')
print('<Exited>') The result is: |
Similar issues: |
Does this issue occur when all extensions are disabled?: Yes
Every new integrated terminal opens /dev/ptmx instead of reusing the old one or opening the new one after closing the old one. This bug occurs both in my WSL and remote Ubuntu server.
Steps to Reproduce when VS Code is connected to WSL (Debian):
a.out
). It's a test program trying to allocate as many fds as possible. It also reports suspicious occupied fds.a.out
in the 1st terminal. The result may be:file
command and its arguments) to the 2nd terminal. The results may be:Conclusion: The first terminal has fds pointing to /dev/urandom and some log files. Every new terminal beginning with the second one opens one more fd pointing to /dev/ptmx and the subprocesses inherit the fds from the terminal.
Other observations: The occupied fds are fixed once the terminal is open. After closing some terminals, the occupied fds in the previously opened terminals are not released, but the fds are released for new terminals.
The results are reproducible on a remote Ubuntu server, except that there is no fd pointing to /dev/urandom, and every new terminal opens /dev/pts/ptmx instead of /dev/ptmx.
I've seen a similar issue: microsoft/vscode#182212, but it doesn't mention WSL or remote servers.
The text was updated successfully, but these errors were encountered: