From d7c8bc9da040652f7b81df3bdba038a5317467aa Mon Sep 17 00:00:00 2001 From: boxmein Date: Sat, 23 Nov 2019 16:50:25 +0200 Subject: [PATCH] Catch errors when trying to derive CWD in Linux, fixes #1576 When the process it tries to read the working dir from has exited, then "/proc/PID/cwd" is an invalid link and fs.readlink() will reject its promise with an error. This results in the terminal "new tab" and "new pane" buttons stopping working, which is very disruptive :( This commit makes sure that the "new tab" and "new pane" buttons keep working, whatever happens. --- terminus-terminal/src/services/sessions.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/terminus-terminal/src/services/sessions.service.ts b/terminus-terminal/src/services/sessions.service.ts index 38af203e..0a3a8257 100644 --- a/terminus-terminal/src/services/sessions.service.ts +++ b/terminus-terminal/src/services/sessions.service.ts @@ -291,7 +291,12 @@ export class Session extends BaseSession { return cwd } if (process.platform === 'linux') { - return fs.readlink(`/proc/${this.truePID}/cwd`) + try { + return await fs.readlink(`/proc/${this.truePID}/cwd`) + } catch (exc) { + console.error(exc) + return null + } } if (process.platform === 'win32') { if (!this.guessedCWD) {