fix shutdown.cpp per a macos (altra volta)

This commit is contained in:
2025-08-11 08:31:30 +02:00
parent 214a4045f0
commit 2bc28d47cd

View File

@@ -91,33 +91,22 @@ namespace SystemShutdown {
}
#elif __APPLE__
// macOS
double delay_minutes = config.delay_seconds / 60.0;
std::string delay_str = "+" + std::to_string(delay_minutes);
if (config.delay_seconds < 60) {
delay_str = "+0.1"; // mínimo delay en macOS
}
// macOS - apagado inmediato
char* args[] = {
const_cast<char*>("shutdown"),
const_cast<char*>("-h"),
const_cast<char*>(delay_str.c_str()),
const_cast<char*>("now"),
NULL
};
return executeUnixShutdown("shutdown", args);
#elif __linux__
// Linux
std::string delay_str = "+" + std::to_string((config.delay_seconds + 59) / 60); // redondear hacia arriba a minutos
if (config.delay_seconds == 0) {
delay_str = "now";
}
// Linux - apagado inmediato
char* args[] = {
const_cast<char*>("shutdown"),
const_cast<char*>("-h"),
const_cast<char*>(delay_str.c_str()),
const_cast<char*>("now"),
NULL
};