Skip to content

Commit

Permalink
Add shutdown support for NetBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
iMilnb committed Feb 4, 2025
1 parent 9223ba5 commit f0f1f7a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/shutdown.cc
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,11 @@ void do_system_shutdown(shutdown_type_t shutdown_type)

sub_buf.append("Issuing shutdown via kernel...\n");
loop.poll(); // give message a chance to get to console
#ifdef __NetBSD__
reboot(reboot_type, NULL);
#else
reboot(reboot_type);
#endif
}

// Watcher for subprocess output.
Expand Down Expand Up @@ -637,7 +641,11 @@ static loop_t::child_proc_watcher::proc_status_t run_process(const char * prog_a
static void unmount_disks(loop_t &loop, subproc_buffer &sub_buf)
{
try {
#ifdef __NetBSD__
const char * unmount_args[] = { "/sbin/umount", "-a", nullptr };
#else
const char * unmount_args[] = { "/bin/umount", "-a", "-r", nullptr };
#endif
run_process(unmount_args, loop, sub_buf);
}
catch (std::exception &e) {
Expand All @@ -650,7 +658,11 @@ static void unmount_disks(loop_t &loop, subproc_buffer &sub_buf)
static void swap_off(loop_t &loop, subproc_buffer &sub_buf)
{
try {
#ifdef __NetBSD__
const char * swapoff_args[] = { "/sbin/swapctl", "-U", nullptr };
#else
const char * swapoff_args[] = { "/sbin/swapoff", "-a", nullptr };
#endif
run_process(swapoff_args, loop, sub_buf);
}
catch (std::exception &e) {
Expand Down

0 comments on commit f0f1f7a

Please sign in to comment.