auraed icon indicating copy to clipboard operation
auraed copied to clipboard

Prevent exit to prevent kernel panic

Open future-highway opened this issue 3 years ago • 3 comments

Via MalteJ, "auraed must not exit if something bad happens. When running as pid 1, we get a kernel panic, when pid 1 exits. We could trigger a reboot instead."

A panic in the daemon will only crash the thread, not the program, as everything is in a thread handled by tokio. As long as tokio's crash/exit is handled, then auraed can be prevented from exiting, hopefully.

A simple loop to restart the daemon may be an appropriate solution:

#[tokio::main]
async fn main() {
    loop {
        let exit_code = daemon().await;
        println!("daemon stopped with exit code: {}", exit_code);
        println!("restarting daemon...");
    }

    panic!("auraed should never exit!");
}

replacing https://github.com/aurae-runtime/auraed/blob/2b274806673ed958fbd5ac799cc7710cf463b758/src/bin/main.rs#L114

future-highway avatar Sep 30 '22 13:09 future-highway

We should add a sleep at the end of the loop. Otherwise, if daemon() exits quickly we'd end up with 100% CPU usage and an infinite loop.

MalteJ avatar Sep 30 '22 13:09 MalteJ

linking related Issue https://github.com/aurae-runtime/auraed/issues/22

Vincinator avatar Oct 01 '22 07:10 Vincinator

catch_unwind may also be useful

future-highway avatar Oct 02 '22 12:10 future-highway