mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
cli: support setting the --parent-process-id in command shell (#193735)
This commit is contained in:
@@ -225,6 +225,9 @@ pub struct CommandShellArgs {
|
|||||||
/// Require the given token string to be given in the handshake.
|
/// Require the given token string to be given in the handshake.
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub require_token: Option<String>,
|
pub require_token: Option<String>,
|
||||||
|
/// Optional parent process id. If provided, the server will be stopped when the process of the given pid no longer exists
|
||||||
|
#[clap(long, hide = true)]
|
||||||
|
pub parent_process_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug, Clone)]
|
#[derive(Args, Debug, Clone)]
|
||||||
|
|||||||
@@ -136,6 +136,11 @@ impl ServiceContainer for TunnelServiceContainer {
|
|||||||
|
|
||||||
pub async fn command_shell(ctx: CommandContext, args: CommandShellArgs) -> Result<i32, AnyError> {
|
pub async fn command_shell(ctx: CommandContext, args: CommandShellArgs) -> Result<i32, AnyError> {
|
||||||
let platform = PreReqChecker::new().verify().await?;
|
let platform = PreReqChecker::new().verify().await?;
|
||||||
|
let mut shutdown_reqs = vec![ShutdownRequest::CtrlC];
|
||||||
|
if let Some(p) = args.parent_process_id.and_then(|p| Pid::from_str(&p).ok()) {
|
||||||
|
shutdown_reqs.push(ShutdownRequest::ParentProcessKilled(p));
|
||||||
|
}
|
||||||
|
|
||||||
let mut params = ServeStreamParams {
|
let mut params = ServeStreamParams {
|
||||||
log: ctx.log,
|
log: ctx.log,
|
||||||
launcher_paths: ctx.paths,
|
launcher_paths: ctx.paths,
|
||||||
@@ -144,7 +149,7 @@ pub async fn command_shell(ctx: CommandContext, args: CommandShellArgs) -> Resul
|
|||||||
.require_token
|
.require_token
|
||||||
.map(AuthRequired::VSDAWithToken)
|
.map(AuthRequired::VSDAWithToken)
|
||||||
.unwrap_or(AuthRequired::VSDA),
|
.unwrap_or(AuthRequired::VSDA),
|
||||||
exit_barrier: ShutdownRequest::create_rx([ShutdownRequest::CtrlC]),
|
exit_barrier: ShutdownRequest::create_rx(shutdown_reqs),
|
||||||
code_server_args: (&ctx.args).into(),
|
code_server_args: (&ctx.args).into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user