pm-utils does not follow requests to inhibit suspend/hibernate from scripts in /etc/pm/sleep.d
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pm-utils |
Confirmed
|
High
|
|||
pm-utils (Debian) |
Fix Released
|
Unknown
|
|||
pm-utils (Ubuntu) |
Fix Released
|
High
|
Brian Murray |
Bug Description
Binary package hint: pm-utils
1) ubuntu version
Description: Ubuntu 10.10
Release: 10.10
2) package version:
pm-utils:
Instalado: 1.4.1-3
Candidato: 1.4.1-3
Tabela de versão:
*** 1.4.1-3 0
500 http://
100 /var/lib/
3) If a script in /etc/pm/sleep.d returns a non-zero value upon requests to suspend or hibernate, the suspend/hibernate process should be aborted.
4) The system ignores the return value and supends/hibernates anyhow.
In order to reproduce the bug just drop the 00_avoid_suspend script in /etc/pm/sleep.d, make it executable and try to sleep.
The system should refuse to sleep but, at least here, it doesn't.
The problems seems to be in the _run_hook() function defined in file /usr/lib/
To walk around I just added a line to store the script return value in a temporary variable and used that variable after the log calls to check the original result. Now it seems to work. My current _run_hook function looks like this:
_run_hook() {
# $1 = hook to run
# rest of args passed to hook unchanged.
log "Running hook $*:"
hook_ok "$1" && "$@"
status=$?
log ""
log -n "$*: "
hook_exit_status $status && LAST_HOOK=
}
Since I am no bash expert, I can not assure that this is a proper solution, but it works here.
tags: | added: patch |
Changed in pm-utils: | |
importance: | Unknown → High |
status: | Unknown → Confirmed |
Changed in pm-utils (Ubuntu): | |
status: | Confirmed → Triaged |
importance: | Undecided → High |
tags: | added: oneiric |
tags: |
added: patch-forwarded-debian removed: patch |
Changed in pm-utils (Debian): | |
status: | Unknown → New |
Changed in pm-utils (Debian): | |
status: | New → Fix Released |
Created attachment 40891
patch for pm-functions.in
Since 1.4.0, _run_hook calls a log() after running the hook, and thus loses the hook exit status:
199 hook_ok "$1" && "$@" "${1##* /}" || inhibit
200 log ""
201 log -n "$*: "
202 hook_exit_status $? && LAST_HOOK=
I attached a simple patch that seems to fix it.
This is important because e.g. a script that unmounts SD/MMC cards before suspending cannot inhibit it if the card is busy (see https:/ /help.ubuntu. com/community/ AspireOne/ Ubuntu9. 10?action= recall& rev=69).
Regards,
Ariel