Properly report closes due to signals
This commit is contained in:
parent
e3a6695399
commit
0a78ef0743
1 changed files with 22 additions and 11 deletions
|
@ -103,20 +103,31 @@ function runRPC(call: any, callback: any): void {
|
||||||
proc.stderr.on("data", (data: string | Buffer) => {
|
proc.stderr.on("data", (data: string | Buffer) => {
|
||||||
console.error(stripEOL(data));
|
console.error(stripEOL(data));
|
||||||
});
|
});
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
resp.setError(err.message);
|
|
||||||
callback(undefined, resp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we got this far, make sure to communicate completion when the process terminates.
|
// If we got this far, make sure to communicate completion when the process terminates.
|
||||||
proc.on("close", (code: number) => {
|
proc.on("close", (code: number, signal: string) => {
|
||||||
|
if (callback !== undefined) {
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
|
if (signal) {
|
||||||
|
resp.setError(`Program exited due to a signal: ${signal}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
resp.setError(`Program exited with non-zero exit code: ${code}`);
|
resp.setError(`Program exited with non-zero exit code: ${code}`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
callback(undefined, resp);
|
callback(undefined, resp);
|
||||||
|
callback = undefined;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
if (callback !== undefined) {
|
||||||
|
resp.setError(err.message);
|
||||||
|
callback(undefined, resp);
|
||||||
|
callback = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function stripEOL(data: string | Buffer): string {
|
function stripEOL(data: string | Buffer): string {
|
||||||
|
|
Loading…
Reference in a new issue