Skip to content

Commit f0e5e93

Browse files
better exit handling in jetty and ash
1 parent edb76a6 commit f0e5e93

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

src/programs/core/ash/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ export default {
6565
continue;
6666
}
6767

68+
// TODO: have an actual builtin processor instead of just reading input here
69+
if (input === "exit") {
70+
running = false;
71+
break;
72+
}
73+
6874
shell.memory.add_history_entry(input);
6975
await shell.execute(input);
7076
}

src/programs/core/ignition/index.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,9 @@ export default {
197197
current_tty_process = boot_target_proc.process;
198198

199199
const exit_code = await boot_target_proc.completion;
200-
201-
if (exit_code === 0) {
202-
running = false;
203-
}
204-
205200
console.log(`boot target ${boot_target} exited with code ${exit_code}`);
206201

207-
// TODO: error recovery logic
202+
// TODO: error recovery logic if boot target fails multiple times in a row
208203
}
209204

210205
return final_code;

src/programs/core/jetty.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type {Program} from "../../types";
22
import type {ProcessContext} from "../../processes";
3+
import {ANSI} from "../../term_ctl";
34

45
export default {
56
name: "jetty",
@@ -57,11 +58,22 @@ export default {
5758

5859
const exit_code = await shell_proc.completion;
5960

60-
if (exit_code === 0) {
61-
running = false;
61+
console.log(`default shell ${default_shell} exited with code ${exit_code}`);
62+
63+
// early break in case jetty is being killed
64+
if (!running) {
65+
break;
6266
}
6367

64-
console.log(`default shell ${default_shell} exited with code ${exit_code}`);
68+
term.reset();
69+
70+
term.writeln(exit_code === 0 ? "Logged out." : `Shell exited with code ${exit_code}!`);
71+
term.writeln(`Press any key to log back in.${ANSI.CURSOR.invisible}`);
72+
73+
await term.wait_for_keypress();
74+
term.write(ANSI.CURSOR.visible);
75+
76+
term.reset();
6577
}
6678

6779
return final_code;

0 commit comments

Comments
 (0)