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.
This commit is contained in:
boxmein 2019-11-23 16:50:25 +02:00
parent a186ae70c7
commit d7c8bc9da0

View File

@ -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) {