Show error name instead of error if shutdown/reboot fails

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion 2025-08-05 08:26:13 +02:00
parent 5bacc8870b
commit cd0accfb28
No known key found for this signature in database
1 changed files with 2 additions and 2 deletions

View File

@ -66,10 +66,10 @@ pub fn main() !void {
// If we can't shutdown or restart due to an error, we print it to standard error. If that fails, just bail out // If we can't shutdown or restart due to an error, we print it to standard error. If that fails, just bail out
if (shutdown) { if (shutdown) {
const shutdown_error = std.process.execv(temporary_allocator, &[_][]const u8{ "/bin/sh", "-c", shutdown_cmd }); const shutdown_error = std.process.execv(temporary_allocator, &[_][]const u8{ "/bin/sh", "-c", shutdown_cmd });
stderr.print("error: couldn't shutdown: {any}\n", .{shutdown_error}) catch std.process.exit(1); stderr.print("error: couldn't shutdown: {s}\n", .{@errorName(shutdown_error)}) catch std.process.exit(1);
} else if (restart) { } else if (restart) {
const restart_error = std.process.execv(temporary_allocator, &[_][]const u8{ "/bin/sh", "-c", restart_cmd }); const restart_error = std.process.execv(temporary_allocator, &[_][]const u8{ "/bin/sh", "-c", restart_cmd });
stderr.print("error: couldn't restart: {any}\n", .{restart_error}) catch std.process.exit(1); stderr.print("error: couldn't restart: {s}\n", .{@errorName(restart_error)}) catch std.process.exit(1);
} else { } else {
// The user has quit Ly using Ctrl+C // The user has quit Ly using Ctrl+C
temporary_allocator.free(shutdown_cmd); temporary_allocator.free(shutdown_cmd);