Handle file errors when finding ports

Fixes #90416
This commit is contained in:
Alex Ross
2020-02-12 10:18:40 +01:00
parent 96f860ddb5
commit 48e5c5b604

View File

@@ -134,8 +134,14 @@ export class ExtHostTunnelService extends Disposable implements IExtHostTunnelSe
}
const ports: { host: string, port: number, detail: string }[] = [];
const tcp: string = fs.readFileSync('/proc/net/tcp', 'utf8');
const tcp6: string = fs.readFileSync('/proc/net/tcp6', 'utf8');
let tcp: string = '';
let tcp6: string = '';
try {
tcp = fs.readFileSync('/proc/net/tcp', 'utf8');
tcp6 = fs.readFileSync('/proc/net/tcp6', 'utf8');
} catch (e) {
// File reading error. No additional handling needed.
}
const procSockets: string = await (new Promise(resolve => {
exec('ls -l /proc/[0-9]*/fd/[0-9]* | grep socket:', (error, stdout, stderr) => {
resolve(stdout);