diff options
author | William Hubbs <william.hubbs@sony.com> | 2019-08-15 12:02:30 -0500 |
---|---|---|
committer | William Hubbs <william.hubbs@sony.com> | 2019-08-15 12:02:30 -0500 |
commit | 0dabda6f6ff3744c6f1b1d2afd57845554384977 (patch) | |
tree | f829361cc302ad0ae84c47dac2399cc5d0edaf3a /src/rc/openrc-shutdown.c | |
parent | 92de9a693b0e4156e404bc69ab230fe2355c22ca (diff) |
fix sysvinit compatibility
This allows openrc to direct sysvinit to shut down the system by setting
the INIT_HALT environment variable appropriately. Also, we do not try to
communicate with sysvinit if its fifo does not exist.
Diffstat (limited to 'src/rc/openrc-shutdown.c')
-rw-r--r-- | src/rc/openrc-shutdown.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/rc/openrc-shutdown.c b/src/rc/openrc-shutdown.c index 4dcd7e16..ec240b2a 100644 --- a/src/rc/openrc-shutdown.c +++ b/src/rc/openrc-shutdown.c @@ -330,16 +330,29 @@ int main(int argc, char **argv) unlink(nologin_file); unlink(shutdown_pid); if (do_halt) { - sysvinit_runlevel('0'); - send_cmd("halt"); + if (exists("/run/initctl")) { + sysvinit_setenv("INIT_HALT", "HALT"); + sysvinit_runlevel('0'); + } else + send_cmd("halt"); } else if (do_kexec) send_cmd("kexec"); - else if (do_poweroff) - send_cmd("poweroff"); - else if (do_reboot) { - sysvinit_runlevel('6'); + else if (do_poweroff) { + if (exists("/run/initctl")) { + sysvinit_setenv("INIT_HALT", "POWEROFF"); + sysvinit_runlevel('0'); + } else + send_cmd("poweroff"); + } else if (do_reboot) { + if (exists("/run/initctl")) + sysvinit_runlevel('6'); + else send_cmd("reboot"); - } else if (do_single) - send_cmd("single"); + } else if (do_single) { + if (exists("/run/initctl")) + sysvinit_runlevel('S'); + else + send_cmd("single"); + } return 0; } |