From 35f474b43e79184e11f502934e6f0d60fcb4fb06 Mon Sep 17 00:00:00 2001 From: Palatosino Date: Fri, 29 Jan 2016 00:33:26 +0100 Subject: [PATCH] Fix process leak You are killing a subprocess without check never the result status, so you are leaking zombie processes: ``` osmc@osmc:~$ ps aux | grep http osmc 19187 0.0 0.0 0 0 ? ZN 22:35 0:00 [torrent2http] osmc 19205 0.0 0.0 0 0 ? ZN 22:35 0:01 [torrent2http] osmc 19258 0.0 0.0 0 0 ? ZN 22:37 0:00 [torrent2http] osmc 19274 1.1 0.0 0 0 ? ZN 22:37 0:19 [torrent2http] osmc 19347 0.1 0.0 0 0 ? ZN 22:39 0:01 [torrent2http] osmc 19363 0.0 0.0 0 0 ? ZN 22:40 0:00 [torrent2http] osmc 19463 0.0 0.0 0 0 ? ZN 22:43 0:00 [torrent2http] osmc 19482 0.0 0.0 0 0 ? ZN 22:44 0:00 [torrent2http] osmc 19498 2.1 0.0 0 0 ? ZN 22:44 0:26 [torrent2http] osmc 19543 0.0 0.0 0 0 ? ZN 22:45 0:00 [torrent2http] osmc 19559 0.0 0.0 0 0 ? ZN 22:45 0:00 [torrent2http] osmc 19576 0.0 0.0 0 0 ? ZN 22:45 0:00 [torrent2http] osmc 19591 2.3 0.0 0 0 ? ZN 22:45 0:28 [torrent2http] osmc 19642 0.0 0.0 0 0 ? ZN 22:47 0:00 [torrent2http] osmc 19658 2.1 0.0 0 0 ? ZN 22:47 0:22 [torrent2http] osmc 19705 2.1 0.0 0 0 ? ZN 22:49 0:19 [torrent2http] ``` With wait() Python reads the termination status and the SO removes the zombie process. --- lib/torrent2http/engine.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/torrent2http/engine.py b/lib/torrent2http/engine.py index 1a99bf4..0b75555 100644 --- a/lib/torrent2http/engine.py +++ b/lib/torrent2http/engine.py @@ -482,6 +482,7 @@ class Engine: else: self._log("torrent2http successfully shut down.") self.wait_on_close_timeout = None + self.process.wait() self.started = False self.logpipe = None self.process = None