Skip to content

Commit 5e4a300

Browse files
committed
comments, more error handling
1 parent b12c07a commit 5e4a300

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

lib/connection/process/basic.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,46 @@ function getProcess (path, args, env) {
6464
reject(err)
6565
})
6666

67+
// catch errors when interacting with ty, just to be safe (errors might crash Atom)
6768
let proc = {
6869
ty: ty,
6970
kill: () => {
71+
// only kill pty if it's still alive:
7072
if (ty._readable || ty._writable) {
7173
try {
7274
ty.kill()
7375
} catch (err) {
76+
console.log('Terminal:')
7477
console.log(err);
7578
}
7679
}
7780
},
78-
interrupt: () => ty.write('\x03'),
81+
interrupt: () => {
82+
try {
83+
ty.write('\x03')
84+
} catch (err) {
85+
console.log('Terminal:')
86+
console.log(err);
87+
}
88+
},
7989
socket: sock,
80-
onExit: (f) => ty.on('exit', f),
90+
onExit: (f) => {
91+
try {
92+
ty.on('exit', f)
93+
} catch (err) {
94+
console.log('Terminal:')
95+
console.log(err);
96+
}
97+
},
8198
onStderr: (f) => {},
82-
onStdout: (f) => ty.on('data', f)
99+
onStdout: (f) => {
100+
try {
101+
ty.on('data', f)
102+
} catch (err) {
103+
console.log('Terminal:')
104+
console.log(err);
105+
}
106+
}
83107
}
84108

85109
resolve(proc)

0 commit comments

Comments
 (0)