Skip to content

Commit 1c416e7

Browse files
committed
shutdown: support differently named shutdown type constants
NetBSD/FreeBSD use RB_HALT rather than Linux's RB_HALT_SYSTEM; For RB_POWER_OFF, FreeBSD uses RB_POWEROFF and NetBSD has RB_POWERDOWN. Resolves davmac314#441
1 parent 3616db3 commit 1c416e7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/shutdown.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,27 @@ void do_system_shutdown(shutdown_type_t shutdown_type)
455455
reboot_type = RB_POWER_OFF;
456456
shutdown_type_arg = "poweroff";
457457
}
458+
#elif defined(RB_POWEROFF)
459+
// FreeBSD spells it slightly differently
460+
if (shutdown_type == shutdown_type_t::POWEROFF) {
461+
reboot_type = RB_POWEROFF;
462+
shutdown_type_arg = "poweroff";
463+
}
464+
#elif defined(RB_POWERDOWN)
465+
// NetBSD (at least) uses RB_POWERDOWN rather than RB_POWER_OFF
466+
if (shutdown_type == shutdown_type_t::POWEROFF) {
467+
reboot_type = RB_POWERDOWN;
468+
shutdown_type_arg = "poweroff";
469+
}
458470
#endif
459471
#if defined(RB_HALT_SYSTEM)
472+
// Linux
460473
if (shutdown_type == shutdown_type_t::HALT) {
461474
reboot_type = RB_HALT_SYSTEM;
462475
shutdown_type_arg = "halt";
463476
}
464477
#elif defined(RB_HALT)
478+
// NetBSD, FreeBSD
465479
if (shutdown_type == shutdown_type_t::HALT) {
466480
reboot_type = RB_HALT;
467481
shutdown_type_arg = "halt";

0 commit comments

Comments
 (0)