diff --git a/applications/services/cli/cli_vcp.c b/applications/services/cli/cli_vcp.c index 6a8afe184..dc1384a44 100644 --- a/applications/services/cli/cli_vcp.c +++ b/applications/services/cli/cli_vcp.c @@ -217,6 +217,7 @@ static void cli_vcp_internal_event_happened(FuriEventLoopObject* object, void* c // disconnect our side of the pipe pipe_detach_from_event_loop(cli_vcp->own_pipe); pipe_free(cli_vcp->own_pipe); + cli_vcp->own_pipe = NULL; // wait for shell to stop cli_shell_join(cli_vcp->shell); diff --git a/lib/toolbox/cli/shell/cli_shell.c b/lib/toolbox/cli/shell/cli_shell.c index 05aecc444..8bf583900 100644 --- a/lib/toolbox/cli/shell/cli_shell.c +++ b/lib/toolbox/cli/shell/cli_shell.c @@ -461,6 +461,9 @@ static void cli_shell_deinit(CliShell* shell) { static int32_t cli_shell_thread(void* context) { CliShell* shell = context; + // Give qFlipper a chance to close and re-open the session + furi_delay_ms(100); + // Sometimes, the other side closes the pipe even before our thread is started. Although the // rest of the code will eventually find this out if this check is removed, there's no point in // wasting time. @@ -469,16 +472,11 @@ static int32_t cli_shell_thread(void* context) { cli_shell_init(shell); FURI_LOG_D(TAG, "Started"); - if(pipe_state(shell->pipe) == PipeStateBroken) goto bail; - shell->motd(shell->callback_context); cli_shell_line_prompt(shell->components[CliShellComponentLine]); - if(pipe_state(shell->pipe) == PipeStateBroken) goto bail; - furi_event_loop_run(shell->event_loop); -bail: FURI_LOG_D(TAG, "Stopped"); cli_shell_deinit(shell); return 0;