SDA-4386 (Properly terminate c9 shell on exiting the application) (#2013)

* SDA-4386 - Properly terminate c9 shell on exiting the application

* SDA-4386 - Wait for the C9 process to terminate
This commit is contained in:
Kiran Niranjan
2023-11-16 14:22:52 +05:30
committed by GitHub
parent a5211a7019
commit 69e70b7350
2 changed files with 11 additions and 4 deletions

View File

@@ -77,7 +77,7 @@ class C9ShellHandler {
/**
* Terminates the c9shell process if it was started by this handler.
*/
public terminateShell() {
public terminateShell = async () => {
if (this._isTerminating) {
logger.info('c9-shell-handler: _isTerminating, skip terminate');
return;
@@ -91,7 +91,12 @@ class C9ShellHandler {
logger.info('c9-shell-handler: terminate');
this._isTerminating = true;
this._c9shell.kill();
}
return new Promise<number>((resolve) => {
this._c9shell?.on('exit', (code) => {
resolve(code || 0);
});
});
};
/**
* Update the current shell status and notify the callback if set.
@@ -246,9 +251,9 @@ export const loadC9Shell = async (sender: WebContents) => {
/**
* Terminates the C9 shell process asynchronously, if it is running.
*/
export const terminateC9Shell = () => {
export const terminateC9Shell = async () => {
if (!c9ShellHandler) {
return;
}
c9ShellHandler.terminateShell();
await c9ShellHandler.terminateShell();
};

View File

@@ -43,6 +43,7 @@ import { AppMenu } from './app-menu';
import { analytics } from './bi/analytics-handler';
import { SDAEndReasonTypes, SDAUserSessionActionTypes } from './bi/interface';
import { closeC9Pipe } from './c9-pipe-handler';
import { terminateC9Shell } from './c9-shell-handler';
import { handleChildWindow } from './child-window-handler';
import {
CloudConfigDataTypes,
@@ -2344,6 +2345,7 @@ export class WindowHandler {
if (shouldRelaunch) {
app.relaunch();
}
await terminateC9Shell();
app.exit();
};