[libcamera-devel] [PATCH 1/3] libcamera: process: fix killing innocent processes unexpectedly

You-Sheng Yang vicamo.yang at canonical.com
Sat Jul 25 14:24:40 CEST 2020


When a libcamera::process is being destructed or called kill() without a
previous successful call to start(), it's pid_ may remains -1, which
causes all the killable processes being killed when passed to
`kill(pid_, SIG_KILL)`.

Signed-off-by: You-Sheng Yang <vicamo.yang at canonical.com>
---
 src/libcamera/process.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp
index e816ee8..8311d27 100644
--- a/src/libcamera/process.cpp
+++ b/src/libcamera/process.cpp
@@ -373,7 +373,8 @@ void Process::died(int wstatus)
  */
 void Process::kill()
 {
-	::kill(pid_, SIGKILL);
+	if (pid_ > 0)
+		::kill(pid_, SIGKILL);
 }
 
 } /* namespace libcamera */
-- 
2.27.0



More information about the libcamera-devel mailing list