Wednesday, May 8, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 2353  / 3 Years ago, mon, september 6, 2021, 12:17:14

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:



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 other java applications.

  • Of course I could create some script, which looks into /proc to sort out processes which belong to snap 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 of snap.

  • I ask this on AskUbuntu, because I only use snap on Ubuntu


More From » snap

 Answers
3

snap is a system for application distribution and installation. Processes spawned from a program installed as a snap are no different from processes of any other software running on the system, and thus are to be managed identically.


In other words, there is nothing specific to processes that are associated with software installed as a snap. Each software package causes one or more processes to be started. Which ones these are are specific to the software.


Thus, no general answer can be given on the question "how to stop processes of a snap package". This comment equally applies if you leave out the word "snap". So really, a specific answer is only possible for specific software.


[#1746] Tuesday, September 7, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
stantildlike

Total Points: 363
Total Questions: 135
Total Answers: 120

Location: Pitcairn Islands
Member since Fri, Dec 17, 2021
2 Years ago
stantildlike questions
Fri, May 5, 23, 00:50, 1 Year ago
Tue, Jun 28, 22, 13:54, 2 Years ago
Tue, Dec 13, 22, 07:27, 1 Year ago
;