Skip to content

Commit

Permalink
scserver: explicitly kill child process
Browse files Browse the repository at this point in the history
In Electron it was re-parenting the scsynth child process rather than shutting it down.
  • Loading branch information
crucialfelix committed Apr 19, 2016
1 parent f96ab62 commit 60627cb
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,22 @@ export class Server extends EventEmitter {

this.processEvents.onNext('Start process: ' + execPath + ' ' + args.join(' '));
this.process = spawn(execPath, args, {
cwd: this.options.cwd
cwd: this.options.cwd,
options: {
detached: false
}
});
this.processEvents.onNext('pid: ' + this.process.pid);

// when this parent process dies, kill child process
process.on('exit', () => {
let killChild = () => {
if (this.process) {
this.process.kill('SIGTERM');
this.process = null;
}
});
};

process.on('exit', killChild);

this.process.on('error', (err) => {
this.processEvents.onError(err);
Expand Down Expand Up @@ -291,7 +297,13 @@ export class Server extends EventEmitter {
this.osc.close();
delete this.osc;
}
this._serverObservers.forEach((obs) => obs.dispose());

// TODO: its the subscriptions that need to be disposed, these are the Observables
// this._serverObservers.forEach((obs) => obs.dispose());
// for (var key in this._serverObservers) {
// console.log(key, this._serverObservers[key], this._serverObservers[key].dispose);
// this._serverObservers[key].dispose();
// }
this._serverObservers = {};
}

Expand Down

0 comments on commit 60627cb

Please sign in to comment.