src/vs/platform/lifecycle/electron-main/lifecycleMainService.ts/LifecycleMainService/relaunch
class LifecycleMainService:	async relaunch(options?: { addArgs?: string[], removeArgs?: string[] }): Promise<void> {
		this.logService.trace('Lifecycle#relaunch()');

		const args = process.argv.slice(1);
		if (options?.addArgs) {
			args.push(...options.addArgs);
		}

		if (options?.removeArgs) {
			for (const a of options.removeArgs) {
				const idx = args.indexOf(a);
				if (idx >= 0) {
					args.splice(idx, 1);
				}
			}
		}

		const quitListener = () => {
			// Windows: we are about to restart and as such we need to restore the original
			// current working directory we had on startup to get the exact same startup
			// behaviour. As such, we briefly change back to that directory and then when
			// Code starts it will set it back to the installation directory again.
			try {
				if (isWindows) {
					const currentWorkingDir = cwd();
					if (currentWorkingDir !== process.cwd()) {
						process.chdir(currentWorkingDir);
					}
				}
			} catch (err) {
				this.logService.error(err);
			}

			// relaunch after we are sure there is no veto
			this.logService.trace('Lifecycle#relaunch() - calling app.relaunch()');
			app.relaunch({ args });
		};
		app.once('quit', quitListener);

		// app.relaunch() does not quit automatically, so we quit first,
		// check for vetoes and then relaunch from the app.on('quit') event
		const veto = await this.quit(true /* will restart */);
		if (veto) {
			app.removeListener('quit', quitListener);
		}
	}