summaryrefslogtreecommitdiff
path: root/src/systemctl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-08-16 22:40:11 +0200
committerLennart Poettering <lennart@poettering.net>2010-08-16 22:40:11 +0200
commit08e4b1c5c8aeb52e806b7cf994173660190e61ab (patch)
treee917904d731b0e677051e1bef4ec0c27a520f574 /src/systemctl.c
parent2396fb04f78eaa9842c747e384218f0069446960 (diff)
shutdown: various fixes for handling of delayed shutdowns
Diffstat (limited to 'src/systemctl.c')
-rw-r--r--src/systemctl.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/systemctl.c b/src/systemctl.c
index 50473a182a..44b884800b 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -3829,7 +3829,7 @@ static int halt_help(void) {
static int shutdown_help(void) {
- printf("%s [OPTIONS...] [now] [WALL...]\n\n"
+ printf("%s [OPTIONS...] [TIME] [WALL...]\n\n"
"Shut down the system.\n\n"
" --help Show this help\n"
" -H --halt Halt the machine\n"
@@ -4137,11 +4137,14 @@ static int parse_time_spec(const char *t, usec_t *_u) {
return -EINVAL;
n = now(CLOCK_REALTIME);
- s = (time_t) n / USEC_PER_SEC;
+ s = (time_t) (n / USEC_PER_SEC);
+
+ zero(tm);
assert_se(localtime_r(&s, &tm));
tm.tm_hour = (int) hour;
tm.tm_min = (int) minute;
+ tm.tm_sec = 0;
assert_se(s = mktime(&tm));
@@ -4239,7 +4242,7 @@ static int shutdown_parse_argv(int argc, char *argv[]) {
return r;
}
} else
- arg_when = USEC_PER_MINUTE;
+ arg_when = now(CLOCK_REALTIME) + USEC_PER_MINUTE;
/* We skip the time argument */
if (argc > optind + 1)
@@ -4819,6 +4822,7 @@ static int halt_main(DBusConnection *bus) {
if (arg_when > 0) {
char *m;
+ char date[FORMAT_TIMESTAMP_MAX];
m = strv_join(arg_wall, " ");
r = send_shutdownd(arg_when,
@@ -4831,8 +4835,11 @@ static int halt_main(DBusConnection *bus) {
if (r < 0)
log_warning("Failed to talk to shutdownd, proceeding with immediate shutdown: %s", strerror(-r));
- else
+ else {
+ log_info("Shutdown scheduled for %s, use 'shutdown -c' to cancel.",
+ format_timestamp(date, sizeof(date), arg_when));
return 0;
+ }
}
if (!arg_dry && !arg_immediate)