Some apps keep my laptop from suspending/hibernating

Hi everyone.

I have installed OpenSuse Leap 15 just a few days ago. Ran updates in a daily bases since then…

Frequently when I have some apps opened, laptop has hard time suspending or hibernating(doesn’t matter if I try graphically or via CLI).

As I have noticed some apps are causing this. Last time it was Microsoft’s Visual Studio Code. I had remote folder mounted using sshfs, and I was editing file from that mounted folder inside vscode. Then because of inactivity, sshfs connection apparently got closed, and so inside editor were files which didn’t exist.

After that I was unable to suspend/hibernate my os. Screen turns off, am getting logged out, but processes still running.

I don’t think issue is with just vscode. I think other apps might cause same issue with right conditions.

Is there a setting to change, so no app will be able to stop Linux from suspending/hibernating?

Thanks a lot in advance :slight_smile:

I guess you could investigate taking steps to ensure the the remote filesystem is not disconnected (if that is the underlying cause of the problem here). The ‘ServerAliveInterval’ can be configured explicitly (in ~/.ssh/config for example) to send null packets after a given number of seconds. (By default, no null packet is sent, so inactivity will generally result in a disconnect depending on how the server is configured.)

Host *
  ServerAliveInterval 60

https://www.ostechnix.com/how-to-stop-ssh-session-from-disconnecting-in-linux/

Other than that I’m not sure what else might prevent suspension, but I don’t encounter such behaviour. Maybe others have further suggestions…

Eh, this might be a different situation, but not that different in that I can suspend ( i never use hibernation ) and resume properly. I don’t use sshfs, but rather a Networkconnection over sftp through Dolphin - Network - Create New Connection. If uses kNetattach and can use various protocols. For my webapp development I use Kate. After creating the new Connection ( with a proper name f.e. Knurpht-VPS ), I drag it to Dolphin’s Places in the side bar. Now, from Kate I can open a file by clicking File - Open - click in Places on Knurpht-VPS and open as many files as my project requires, edit and save them. So far the use case, so you see it’s about the same: working on a remote project.

Now, I don’t work continuously on the same code, have the routine to close the lid of my laptop, which puts it to suspend. If I open the lid again, unlock, I can see the network connection be reeastablished and the entire Kate session is intact, i.e. I can change and save files, no data loss.

Maybe this gives you some options…

Thanks guys for your kind replies :slight_smile:

Today and yesterday I have tried to reproduce the problem multiple times.

Yesterday weird thing happened… It wasn’t suspending even when closing vscode… When I closed the terminal, it started working again.

Now I am trying to see if other editors will cause same thing, but none of them do… Issue seems to be connected with sshfs combined with vscode.

Note that this time sshfs connection was wasn’t closed, but the issue still persisted.

Isn’t there a way to configure system, so it will force every app to suspend?

I haven’t encountered a situation like this (and I’m not familiar with vscode at all), so can only provide general advice here. Since you categorically state that it prevents suspend (and I assume shutdown) from occurring, I’m wondering if perhaps it is using a systemd inhibitor lock perhaps? This is complete speculation on my part though.

https://www.freedesktop.org/wiki/Software/systemd/inhibit/

I note that there are two PolKit policies that can be tweaked to prevent user applications from having the ability to block or delay such an action
‘org.freedesktop.login1.inhibit-block-sleep’ and ‘org.freedesktop.login1.inhibit-delay-sleep’, and the default policies are as follows

 # pkaction -av org.freedesktop.login1.inhibit-block-sleep
org.freedesktop.login1.inhibit-block-sleep:
  description:       Allow applications to inhibit system sleep
  message:           Authentication is required for an application to inhibit system sleep.
  vendor:            The systemd Project
  vendor_url:        http://www.freedesktop.org/wiki/Software/systemd
  icon:              
  implicit any:      no
  implicit inactive: yes
  implicit active:   yes
  annotation:        org.freedesktop.policykit.imply -> org.freedesktop.login1.inhibit-delay-sleep org.freedesktop.login1.inhibit-block-idle

 # pkaction -av org.freedesktop.login1.inhibit-delay-sleep
org.freedesktop.login1.inhibit-delay-sleep:
  description:       Allow applications to delay system sleep
  message:           Authentication is required for an application to delay system sleep.
  vendor:            The systemd Project
  vendor_url:        http://www.freedesktop.org/wiki/Software/systemd
  icon:              
  implicit any:      yes
  implicit inactive: yes
  implicit active:   yes

 # 

As well as this, there is an option to limit ‘delay’ inhibitor locks to a maximum time interval. (This won’t have any effect if a ‘block’ inhibitor is employed though.)

InhibitDelayMaxSec=
Specifies the maximum time a system shutdown or sleep request is delayed due to an inhibitor lock of type “delay” being active before the inhibitor is
ignored and the operation executes anyway. Defaults to 5.

Reference ‘man logind.conf’

I’ll leave you to explore this further.

Found the funny fix actually. Even though I don’t have an external monitor connected, this works:

In **Energy Saving, **option suspend **even when an external is connected - **must be ticked.

It now suspends successfully when LID is closed, though normal suspending still doesn’t work. I suppose neither does hibernating…

I will look into this later and will post solution for anyone who might encounter similar problem.

Everyone thanks for time and attention :slight_smile:

Okay… It worked before… Now it does same thing again :confused:

I’m not surprised to read this - it seemed unlikely to me.

I tried some different things on the mounted folder and I have discovered weird thing… root can’t access it! only my user can. How is that possible?

it writes this when I try to cd in that directory: **bash: cd: folder Permission denied **