Public bug reported:

If user's computer goes power-off when suspended or suspend operation
fails for some reason (possibly by faulty suspend script at
/etc/pm/sleep.d/) this may lead to a situation where suspend isn't
possible anymore, because /.suspended file exists and it contains pid
that exists, but has nothing to do with ongoing suspend operation.

In /usr/lib/pm-utils/functions there are some what faulty locking
functions. First take_suspend_lock checks if /.suspended exists and if
not it creates it and same file is removed in remove_suspend_lock. I
don't quite understand why such file is needed and especially why it
exists outside take_suspend_lock.

Here are those functions:

take_suspend_lock()
{
        VT=$(fgconsole)
        chvt 63
        if [ -f /.suspended ]; then
                read pid < /.suspended
                if [ -d /proc/$pid ]; then
                        return 1
                fi
        fi
        echo "$$" > /.suspended
        rm -f /var/run/pm-suspend
        touch /var/run/pm-suspend
        return 0
}

remove_suspend_lock()
{
        rm -f /var/run/pm-suspend
        # This call will cause terminal corruption when using fglrx. This is a 
work around only.
        # Tested and suggested by AMD/AGP (ATI) Linux engineering group
        if ! grep -q fglrx /proc/modules; then
                chvt 1
        fi
        chvt $VT
        openvt -- sh -c "sleep $1 ; rm -f /.suspended >/dev/null 2>&1 0<&1" 
>/dev/null 2>&1 0<&1 &
}

I think that /.suspended could be removed inside take_suspend_lock when
/var/run/pm-suspend is created.

I attached a patch to do this, but I'm not sure if my modifications are
correct, but it seems to work for me.  Why is that /.suspended file even
needed.

** Affects: pm-utils (Ubuntu)
     Importance: Undecided
         Status: New

-- 
take_suspend_lock may end-up with persistent locking
https://bugs.launchpad.net/bugs/246951
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to