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

* 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:27:46 +05:30
committed by GitHub
parent ee7ce7d5a5
commit 4611f66143
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. * Terminates the c9shell process if it was started by this handler.
*/ */
public terminateShell() { public terminateShell = async () => {
if (this._isTerminating) { if (this._isTerminating) {
logger.info('c9-shell-handler: _isTerminating, skip terminate'); logger.info('c9-shell-handler: _isTerminating, skip terminate');
return; return;
@@ -91,7 +91,12 @@ class C9ShellHandler {
logger.info('c9-shell-handler: terminate'); logger.info('c9-shell-handler: terminate');
this._isTerminating = true; this._isTerminating = true;
this._c9shell.kill(); 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. * 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. * Terminates the C9 shell process asynchronously, if it is running.
*/ */
export const terminateC9Shell = () => { export const terminateC9Shell = async () => {
if (!c9ShellHandler) { if (!c9ShellHandler) {
return; return;
} }
c9ShellHandler.terminateShell(); await c9ShellHandler.terminateShell();
}; };

View File

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