Wait for inner process to exit
This commit is contained in:
parent
055e0ef9ec
commit
3c6fac9ce4
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user