diff options
authorLennart Poettering <>2018-10-24 13:04:30 +0200
committerSven Eden <>2018-10-29 10:18:39 +0100
commit0311ed6e95c029f52067d81f04bd84fb496db9dc (patch)
parent3a3c3994e958ddbaa5ec6a7a0659245dc8d2b5bc (diff)
sleep: rework what we do if a suspend fails.
First of all, let's fix logging: let's simply log the same message as we do on success, so that there's always the same pair of these messages around, regardless if the suspend was successful or not. To distuingish a successful suspend from a failed one, check the ERRNO= field of the structured message. In most ways a failed suspend cycle is not distuingishable from a successful one that took no time, hence let's treat it this way, and always pair the success message with a failure message. This also changes a more important concept: the post-suspend callouts are now called also called on failure, following the same logic: let's always run them in pairs: for every pre callout a post callout has to follow. (cherry picked from commit 14250f0942b0c1122a35d678e73945d7adf9cfa0)
1 files changed, 9 insertions, 6 deletions
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index 890dae7ab..e740a26e7 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -188,12 +188,15 @@ static int execute(Manager *m, const char *verb) {
r = write_state(&f, states);
if (r < 0)
- return log_error_errno(r, "Failed to write /sys/power/state: %m");
- log_struct(LOG_INFO,
- LOG_MESSAGE("System resumed."),
- "SLEEP=%s", arg_verb);
+ log_struct_errno(LOG_ERR, r,
+ LOG_MESSAGE("Failed to suspend system. System resumed again: %m"),
+ "SLEEP=%s", arg_verb);
+ else
+ log_struct(LOG_INFO,
+ LOG_MESSAGE("System resumed."),
+ "SLEEP=%s", arg_verb);
arguments[1] = (char*) "post";
execute_directories(dirs, DEFAULT_TIMEOUT_USEC, NULL, NULL, arguments, NULL);