]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
container: Allow stopping without killing the session deamon
authorAlessandro Astone <ales.astone@gmail.com>
Tue, 17 Jan 2023 22:11:05 +0000 (23:11 +0100)
committerAlessandro Astone <ales.astone@gmail.com>
Tue, 17 Jan 2023 22:13:24 +0000 (23:13 +0100)
Useful for restarting the container, e.g. with the following sequence:

  session = DBusContainerService().GetSession()
  DBusContainerService().Stop(False)
  DBusContainerService().Start(session)

tools/actions/container_manager.py
tools/actions/session_manager.py

index ddfc3bbc9db11422fe217f687f758e1402241020..7321c148dcf5e3f991347d9df2170516fd9e28a6 100644 (file)
@@ -26,9 +26,9 @@ class DbusContainerManager(dbus.service.Object):
     def Start(self, session):
         do_start(self.args, session)
 
-    @dbus.service.method("id.waydro.ContainerManager", in_signature='', out_signature='')
-    def Stop(self):
-        stop(self.args)
+    @dbus.service.method("id.waydro.ContainerManager", in_signature='b', out_signature='')
+    def Stop(self, quit_session):
+        stop(self.args, quit_session)
 
     @dbus.service.method("id.waydro.ContainerManager", in_signature='', out_signature='')
     def Freeze(self):
@@ -166,7 +166,7 @@ def do_start(args, session):
 
     args.session = session
 
-def stop(args):
+def stop(args, quit_session=True):
     try:
         services.hardware_manager.stop(args)
         status = helpers.lxc.status(args)
@@ -200,10 +200,11 @@ def stop(args):
         helpers.mount.umount_all(args, tools.config.defaults["data"])
 
         if "session" in args:
-            try:
-                os.kill(int(args.session["pid"]), signal.SIGUSR1)
-            except:
-                pass
+            if quit_session:
+                try:
+                    os.kill(int(args.session["pid"]), signal.SIGUSR1)
+                except:
+                    pass
             del args.session
     except:
         pass
index c1d4271140a220c45169f23fcc64944c66466715..242125622530cef06366941ae93bb69aa0e78d1a 100644 (file)
@@ -24,7 +24,7 @@ class DbusSessionManager(dbus.service.Object):
     @dbus.service.method("id.waydro.SessionManager", in_signature='', out_signature='')
     def Stop(self):
         do_stop(self.args, self.looper)
-        stop_container()
+        stop_container(quit_session=False)
 
 def service(args, looper):
     dbus_obj = DbusSessionManager(looper, dbus.SessionBus(), '/SessionManager', args)
@@ -76,7 +76,7 @@ def start(args, unlocked_cb=None):
 
     def sigint_handler(data):
         do_stop(args, mainloop)
-        stop_container()
+        stop_container(quit_session=False)
 
     def sigusr_handler(data):
         do_stop(args, mainloop)
@@ -106,10 +106,10 @@ def stop(args):
     try:
         tools.helpers.ipc.DBusSessionService().Stop()
     except dbus.DBusException:
-        stop_container()
+        stop_container(quit_session=True)
 
-def stop_container():
+def stop_container(quit_session):
     try:
-        tools.helpers.ipc.DBusContainerService().Stop()
+        tools.helpers.ipc.DBusContainerService().Stop(quit_session)
     except dbus.DBusException:
         pass