This question is odd. Please note that this is not an android-studio
question but a snap
question. android-studio
only is one culprit which misbehaves and should be restrained by snap
.
android-studio
was installed via snap
. But sometimes processes still hang in the background and eat a lot of CPU (and hence battery power) after closing android-studio
. Then I need to kill those manually using the process ID with switch -9
.
Is this really the intended way? With snap
?
I tried to find any pointer on Internet but failed completely how to do that with the help of snap
. Either the commands do not even seem to exist or nothing helped or was completely wrong. Also snap documentation seems to hide the bit I am looking for very well (or is it missing?).
Note that all the common things are no problem at all:
- Install a package from Ubuntu
- Remove a package
- Use a package (works mostly the way I want it)
- Properly update a package (after days of googling I finally found a workaround which automatically keeps things tidy)
But I am still puzzled how am I supposed to control an app in a snap package properly:
Well, it's snap
, so everything is neatly packaged, right? And there certainly is some common easy way to fully stop everything in such a snap container, right?
For example, with lxc-stop container
everything in the container is teared down. Easy. But with snap
I found nothing similar.
Here is what I tried and was partially suggested by other pages:
$ snap status
error: unknown command "status", see 'snap help'.
$ snap stop android-studio
error: access denied (try with sudo)
It was started as a user, so the same user must be able to stop it again. sudo
certainly is of reach here, but let's retry with sudo
:
$ sudo snap stop android-studio
error: snap "android-studio" has no services
$ killall android-studio
android-studio: no process found
But with ps
and top
or htop
there are processes (partly java
, of course):
$ ps auxwww | grep android
tino 14352 0.0 0.0 2616 1732 ? S 12:48 0:00 /bin/sh /snap/android-studio/101/android-studio/bin/studio.sh
tino 14428 4.7 10.6 5042148 420488 ? Sl 12:48 2:19 /snap/android-studio/101/android-studio/jre/bin/java -classpath /snap/android-studio/101/android-studio/lib/bootstrap.jar:/snap/android-studio/101/android-studio/lib/extensions.jar:/snap/android-studio/101/android-studio/lib/util.jar:/snap/android-studio/101/android-studio/lib/jdom.jar:/snap/android-studio/101/android-studio/lib/log4j.jar:/snap/android-studio/101/android-studio/lib/trove4j.jar:/snap/android-studio/101/android-studio/lib/jna.jar:/snap/android-studio/101/android-studio/jre/lib/tools.jar -Xms256m -Xmx1280m -XX:ReservedCodeCacheSize=240m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -Dsun.io.useCanonPrefixCache=false -Djdk.http.auth.tunneling.disabledSchemes="" -Djdk.attach.allowAttachSelf=true -Dkotlinx.coroutines.debug=off -Djdk.module.illegalAccess.silent=true -Djna.nosys=true -Djna.boot.library.path= -Didea.vendor.name=Google -Dawt.useSystemAAFontSettings=lcd -Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine -Dsun.tools.attach.tmp.only=true -XX:ErrorFile=/home/tino/java_error_in_STUDIO_%p.log -XX:HeapDumpPath=/home/tino/java_error_in_STUDIO.hprof -Didea.paths.selector=AndroidStudio4.1 -Djb.vmOptionsFile=/snap/android-studio/101/android-studio/bin/studio64.vmoptions -Didea.platform.prefix=AndroidStudio -Didea.jre.check=true com.intellij.idea.Main
tino 45016 0.0 0.0 11128 2452 pts/12 S+ 13:37 0:00 grep --color=auto android
$ kill 14352
$ kill 14352
-bash: kill: (14352) - No such process
$ kill 14428
$ kill 14428
$ ps auxwww | grep android
tino 14428 4.7 10.6 5042148 420488 ? Sl 12:48 2:19 /snap/android-studio/101/android-studio/jre/bin/java -classpath /snap/android-studio/101/android-studio/lib/bootstrap.jar:/snap/android-studio/101/android-studio/lib/extensions.jar:/snap/android-studio/101/android-studio/lib/util.jar:/snap/android-studio/101/android-studio/lib/jdom.jar:/snap/android-studio/101/android-studio/lib/log4j.jar:/snap/android-studio/101/android-studio/lib/trove4j.jar:/snap/android-studio/101/android-studio/lib/jna.jar:/snap/android-studio/101/android-studio/jre/lib/tools.jar -Xms256m -Xmx1280m -XX:ReservedCodeCacheSize=240m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -Dsun.io.useCanonPrefixCache=false -Djdk.http.auth.tunneling.disabledSchemes="" -Djdk.attach.allowAttachSelf=true -Dkotlinx.coroutines.debug=off -Djdk.module.illegalAccess.silent=true -Djna.nosys=true -Djna.boot.library.path= -Didea.vendor.name=Google -Dawt.useSystemAAFontSettings=lcd -Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine -Dsun.tools.attach.tmp.only=true -XX:ErrorFile=/home/tino/java_error_in_STUDIO_%p.log -XX:HeapDumpPath=/home/tino/java_error_in_STUDIO.hprof -Didea.paths.selector=AndroidStudio4.1 -Djb.vmOptionsFile=/snap/android-studio/101/android-studio/bin/studio64.vmoptions -Didea.platform.prefix=AndroidStudio -Didea.jre.check=true com.intellij.idea.Main
tino 45020 0.0 0.0 11128 2544 pts/12 S+ 13:37 0:00 grep --color=auto android
$ kill -9 14428
$ kill -9 14428
-bash: kill: (14428) - No such process
Apparently some are die-hards and need -9
to be killed!
Notes:
- I do not want to use
killall java
, because this will affect otherjava
applications. - Of course I could create some script, which looks into
/proc
to sort out processes which belong tosnap
and operate on this. - But I am looking for a command which involves
snap
instead of re-inventing the wheel with some independent external command based on internals ofsnap
. - I ask this on AskUbuntu, because I only use
snap
on Ubuntu