Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/halt/halt.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ while getopts :nwdfiph opt; do
n) ;;
w) poweroff_arg=--write-only ;;
d) option_arg=--no-write ;;
f) ;;
f) option_arg=--force;;
i) ;;
p) poweroff_arg=--poweroff ;;
[?]) printf "%s\n" "${0##*/}: invalid command line option" >&2
Expand Down
11 changes: 10 additions & 1 deletion src/openrc-shutdown/openrc-shutdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <sys/reboot.h>
#include <sys/types.h>
#include <strings.h>
#include <unistd.h>
Expand All @@ -48,6 +49,7 @@ const char getoptstring[] = "cdDfFHKpRrsw" getoptstring_COMMON;
const struct option longopts[] = {
{ "cancel", no_argument, NULL, 'c'},
{ "no-write", no_argument, NULL, 'd'},
{ "force", no_argument, NULL, 'f'},
{ "dry-run", no_argument, NULL, 'D'},
{ "halt", no_argument, NULL, 'H'},
{ "kexec", no_argument, NULL, 'K'},
Expand All @@ -61,6 +63,7 @@ const struct option longopts[] = {
const char * const longopts_help[] = {
"cancel a pending shutdown",
"do not write wtmp record",
"force the shutdown"
"print actions instead of executing them",
"halt the system",
"reboot the system using kexec",
Expand Down Expand Up @@ -96,6 +99,7 @@ static bool do_reexec = false;
static bool do_single = false;
static bool do_wtmp = true;
static bool do_wtmp_only = false;
static bool do_force = false;

static void cancel_shutdown(void)
{
Expand Down Expand Up @@ -208,6 +212,9 @@ int main(int argc, char **argv)
case 'd':
do_wtmp = false;
break;
case 'f':
do_force = true;
break;
case 'D':
do_dryrun = true;
break;
Expand Down Expand Up @@ -347,7 +354,9 @@ int main(int argc, char **argv)
} else
send_cmd("poweroff");
} else if (do_reboot) {
if (access("/run/initctl", F_OK) == 0)
if (do_force)
reboot(RB_AUTOBOOT); /* hard reboot */
else if (access("/run/initctl", F_OK) == 0)
sysvinit_runlevel('6');
else
send_cmd("reboot");
Expand Down
4 changes: 2 additions & 2 deletions src/reboot/reboot.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ while getopts :nwdfhik opt; do
case "$opt" in
n) ;;
w) poweroff_arg=--write-only ;;
d) option_arg=--no-write ;;
f) ;;
d) option_arg="${option_arg:+$option_arg }--no-write" ;;
f) option_arg="${option_arg:+$option_arg }--force" ;;
h) ;;
i) ;;
k) poweroff_arg=--kexec ;;
Expand Down
Loading