feat: add force_terminate command
This commit is contained in:
parent
6e2c149088
commit
16ec05c75b
2 changed files with 8 additions and 2 deletions
|
@ -237,7 +237,7 @@ pub fn main() anyerror!void {
|
|||
var final_exit_status: u8 = 0;
|
||||
var want_restart: bool = false;
|
||||
|
||||
fn print_exit_status(_: void, msg: []const u8) void {
|
||||
pub fn print_exit_status(_: void, msg: []const u8) void {
|
||||
if (std.mem.eql(u8, msg, "normal")) {
|
||||
return;
|
||||
} else if (std.mem.eql(u8, msg, "restart")) {
|
||||
|
@ -314,7 +314,7 @@ fn trace_to_file(m: thespian.message.c_buffer_type) callconv(.C) void {
|
|||
buffer.flush() catch {};
|
||||
}
|
||||
|
||||
fn exit(status: u8) noreturn {
|
||||
pub fn exit(status: u8) noreturn {
|
||||
if (builtin.os.tag == .linux) {
|
||||
// drain stdin so we don't leave junk at the next prompt
|
||||
_ = std.os.linux.syscall3(.ioctl, @as(usize, @bitCast(@as(isize, std.posix.STDIN_FILENO))), std.os.linux.T.CFLSH, 0);
|
||||
|
|
|
@ -514,6 +514,12 @@ const cmds = struct {
|
|||
try tp.self_pid().send("restart");
|
||||
}
|
||||
|
||||
pub fn force_terminate(self: *Self, _: Ctx) Result {
|
||||
self.deinit();
|
||||
root.print_exit_status({}, "FORCE TERMINATE");
|
||||
root.exit(99);
|
||||
}
|
||||
|
||||
pub fn theme_next(self: *Self, _: Ctx) Result {
|
||||
self.theme = get_next_theme_by_name(self.theme.name);
|
||||
self.config.theme = self.theme.name;
|
||||
|
|
Loading…
Add table
Reference in a new issue