diff options
author | Victor Lowther <victor.lowther@gmail.com> | 2009-12-07 19:02:35 -0600 |
---|---|---|
committer | Victor Lowther <victor.lowther@gmail.com> | 2009-12-07 19:02:35 -0600 |
commit | 09da44bedc97ddd75e77ed87b7a057dc21e01a38 (patch) | |
tree | c534c5702766f19e841bdf259e8da271268c5e89 /src | |
parent | 57ff1f997d6297557340057e9fdbb2f956b31aa0 (diff) |
Track suspend/hibernate failures and exit accordingly.
It turns out that echo whatever >/sys/power/state will fail if
transitioning to that state fails. If transitioning to the
reuested power state fails, pm-action will return an error code
greater or equal than 128.
Diffstat (limited to 'src')
-rwxr-xr-x | src/pm-action.in | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pm-action.in b/src/pm-action.in index 88bdb4e..e148585 100755 --- a/src/pm-action.in +++ b/src/pm-action.in @@ -29,6 +29,9 @@ export STASHNAME=pm-suspend export METHOD="$(echo ${0##*pm-} |tr - _)" . "@PM-UTILS-LIBDIR@/pm-functions" +# return code tracking for when suspend fails +r=0 + help() { echo "${0##*/} [options]" @@ -97,7 +100,7 @@ if run_hooks sleep "$ACTION $METHOD"; then # Sleep only if we know how and if a hook did not inhibit us. log "$(date): performing $METHOD" sync - "do_$METHOD" + "do_$METHOD" || r=128 log "$(date): Awake." else log "$(date): Inhibit found, will not perform $METHOD" @@ -107,5 +110,6 @@ log "$(date): Running hooks for $REVERSE" if run_hooks sleep "$REVERSE $METHOD" reverse; then log "$(date): Finished." else - exit 1 + exit $((r+1)) fi +exit $r |