diff --git a/cli/src/commands/args.rs b/cli/src/commands/args.rs index d1bee378ef2..7863635ae99 100644 --- a/cli/src/commands/args.rs +++ b/cli/src/commands/args.rs @@ -225,6 +225,9 @@ pub struct CommandShellArgs { /// Require the given token string to be given in the handshake. #[clap(long)] pub require_token: Option, + /// 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, } #[derive(Args, Debug, Clone)] diff --git a/cli/src/commands/tunnels.rs b/cli/src/commands/tunnels.rs index e9ca2277d9f..c0b3f3f01f9 100644 --- a/cli/src/commands/tunnels.rs +++ b/cli/src/commands/tunnels.rs @@ -136,6 +136,11 @@ impl ServiceContainer for TunnelServiceContainer { pub async fn command_shell(ctx: CommandContext, args: CommandShellArgs) -> Result { 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 { log: ctx.log, launcher_paths: ctx.paths, @@ -144,7 +149,7 @@ pub async fn command_shell(ctx: CommandContext, args: CommandShellArgs) -> Resul .require_token .map(AuthRequired::VSDAWithToken) .unwrap_or(AuthRequired::VSDA), - exit_barrier: ShutdownRequest::create_rx([ShutdownRequest::CtrlC]), + exit_barrier: ShutdownRequest::create_rx(shutdown_reqs), code_server_args: (&ctx.args).into(), };