Skip to content

Commit 5c21a9d

Browse files
committed
properly close all terminals on sigint
1 parent 1c2097e commit 5c21a9d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

server.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ app.post('/terminals', function (req, res) {
101101
rows = parseInt(req.query.rows),
102102
cwd = req.query.cwd;
103103

104-
console.log(cwd);
105-
106104
var term = pty.spawn(process.platform === 'win32' ? 'cmd.exe' : 'bash', [], {
107105
name: 'xterm-color',
108106
cols: cols || 80,
@@ -172,7 +170,6 @@ app.use(errorHandler);
172170

173171
serverInitialization(app);
174172

175-
176173
function errorHandler(err, req, res, next) {
177174
winston.error(err);
178175
if (err.name === "InternalOAuthError") {
@@ -250,6 +247,14 @@ function mount_dav(server) {
250247

251248
process.on('SIGINT', function() {
252249
winston.info("\nShutting down from SIGINT");
250+
console.log(terminals);
251+
252+
Object.keys(terminals).forEach(function (pid) {
253+
var term = terminals[pid];
254+
console.log('Closed terminal ' + term.pid);
255+
term.kill();
256+
});
257+
253258
// some other closing procedures go here
254259
debug_helper.kill_debug(false, function() {
255260
//no need to wait for this

0 commit comments

Comments
 (0)