diff options
author | Victor Lowther <victor.lowther@gmail.com> | 2008-06-01 12:10:14 -0500 |
---|---|---|
committer | Victor Lowther <victor.lowther@gmail.com> | 2008-06-01 12:10:14 -0500 |
commit | 0218a2dd4a87a2d4966eb0c49843c2773dc36453 (patch) | |
tree | 47aa9273d5c2d495566409d5b71b7e64aba0abc9 /src | |
parent | df34a14f1875c8bf650efbd0a9fa0a7561aa1677 (diff) |
Add initial support for handling hook failure
If a hook exits with a status code other then 0 or one of the
already-defined exit codes:
* Inhibit suspend/resume, and do not run any more hooks.
* Track the last sucessful hook that ran, and if we have to run hooks
in reverse start with that hook.
* If we inhibited for any reason, exit with a non-zero return code from
pm-action.
Diffstat (limited to 'src')
-rwxr-xr-x | src/pm-action.in | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/pm-action.in b/src/pm-action.in index d4ddec6..58a20b6 100755 --- a/src/pm-action.in +++ b/src/pm-action.in @@ -82,9 +82,8 @@ rm -f "${INHIBIT}" # run the sleep hooks log "$(date): Running hooks for $ACTION." -run_hooks sleep "$ACTION" -# Sleep only if we know how and if a hook did not inhibit us. -if [ ! -e "$INHIBIT" ]; then +if run_hooks sleep "$ACTION"; then + # Sleep only if we know how and if a hook did not inhibit us. log "$(date): performing $METHOD" sync "do_$METHOD" @@ -94,5 +93,8 @@ else fi log "$(date): Running hooks for $REVERSE" # run the sleep hooks in reverse with the wakeup action -run_hooks sleep "$REVERSE" reverse -log "$(date): Finished." +if run_hooks sleep "$REVERSE" reverse; then + log "$(date): Finished." +else + exit 1 +fi |