Bug 417502

Summary: Sleep does not work if you close the laptop lid too fast after specifying that you want to power off.
Product: [Plasma] Powerdevil Reporter: John van Spaandonk <jwork123nl>
Component: generalAssignee: Plasma Bugs List <plasma-bugs>
Status: REPORTED ---    
Severity: normal CC: jwork123nl, kde
Priority: NOR    
Version: 5.18.0   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:

Description John van Spaandonk 2020-02-12 16:12:56 UTC
SUMMARY
My laptop is set up to power off if I press the power button, and to go to sleep if I close the laptop lid. No screensaver active when the problem occurs. Also no full-screen video.

STEPS TO REPRODUCE
1. Press power button to put laptop to sleep
2. Close laptop lid directly after pressing power button
3. that's it!

OBSERVED RESULT
Laptop goes to sleep (suspend?), apparently erroneously triggered by closing  the laptop lid.

EXPECTED RESULT
The laptop should power off. I asked it to and it should not ignore it and do something else instead.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
This bug has been there for years. It looks like the developers did not test this scenario.
No idea if the problem is in Powerdevil or not, feel free to reassign to appropriate component. Also let me know what other info you want!
Comment 1 Kai Uwe Broulik 2020-02-12 16:15:55 UTC
There's definitely code in Powerdevil that checks if ksmserver is exiting and then ignores the suspend request.
Possible that PowerDevil at this point was already killed and then logind takes over and just goes ahead anyway.
Comment 2 John van Spaandonk 2020-02-13 05:49:10 UTC
On 2020-02-12 17:15, Kai Uwe Broulik wrote:
> https://bugs.kde.org/show_bug.cgi?id=417502
>
> Kai Uwe Broulik <kde@privat.broulik.de> changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                   CC|                            |kde@privat.broulik.de
>
> --- Comment #1 from Kai Uwe Broulik <kde@privat.broulik.de> ---
> There's definitely code in Powerdevil that checks if ksmserver is exiting and
> then ignores the suspend request.
> Possible that PowerDevil at this point was already killed and then logind takes
> over and just goes ahead anyway.
>
I think that powermanagement in particular benefits from a system-wide 
development view.
Too bad I do not have any experience with this.
As a first step, is this problem reproducable?