1
0
mirror of https://git.tuxpa.in/a/code-server.git synced 2024-12-27 20:55:25 +00:00

Wait for inner process to exit

This commit is contained in:
Asher 2021-01-20 15:29:45 -06:00
parent 055e0ef9ec
commit 3c6fac9ce4
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A

View File

@ -234,9 +234,7 @@ export class ParentProcess extends Process {
this.logStdoutStream = rfs.createStream(path.join(paths.data, "coder-logs", "code-server-stdout.log"), opts)
this.logStderrStream = rfs.createStream(path.join(paths.data, "coder-logs", "code-server-stderr.log"), opts)
this.onDispose(() => {
this.disposeChild()
})
this.onDispose(() => this.disposeChild())
this.onChildMessage((message) => {
switch (message.type) {
@ -252,11 +250,15 @@ export class ParentProcess extends Process {
})
}
private disposeChild(): void {
private async disposeChild(): Promise<void> {
this.started = undefined
if (this.child) {
this.child.removeAllListeners()
this.child.kill()
const child = this.child
child.removeAllListeners()
child.kill()
// Wait for the child to exit otherwise its output will be lost which can
// be especially problematic if you're trying to debug why cleanup failed.
await new Promise((r) => child!.on("exit", r))
}
}