diff --git a/apps/desktop/src/app/DesktopCliShim.ts b/apps/desktop/src/app/DesktopCliShim.ts index 0f7e605da6b36..0358849840ddd 100644 --- a/apps/desktop/src/app/DesktopCliShim.ts +++ b/apps/desktop/src/app/DesktopCliShim.ts @@ -119,12 +119,18 @@ export const renderCliShim = (input: { // Ctrl-C to the CLI directly. A background child would read /dev/null, so pass stdin on fd 9. // With stdin closed, `exec 9<&0` would end the shell; `command` makes it a normal error. "{ command exec 9<&0; } 2>/dev/null || exec 9/dev/null; else stop=TERM; fi' TERM`, + `trap 'if [ -n "$cli" ]; then kill -HUP "$cli" 2>/dev/null; else stop=HUP; fi' HUP`, + // Ctrl-C goes to the CLI directly; the launcher stays to unmount after it exits. + "trap ':' INT", `${run("$mount")} <&9 9<&- &`, "cli=$!", "exec 9<&-", - `trap 'kill -TERM "$cli" 2>/dev/null' TERM`, - `trap 'kill -HUP "$cli" 2>/dev/null' HUP`, - "trap '' INT", + '[ -z "$stop" ] || kill -"$stop" "$cli" 2>/dev/null', "status=0", 'wait "$cli" || status=$?', // A trapped signal interrupts wait; wait again for the CLI's own exit status.