From 774f0d1b9b59f5a779d0bf257b365f307cf191f8 Mon Sep 17 00:00:00 2001 From: You-Sheng Yang Date: Sat, 25 Jul 2020 20:24:40 +0800 Subject: libcamera: process: Fix killing innocent processes unexpectedly 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 Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/libcamera/process.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libcamera/process.cpp') diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp index e816ee86..8311d274 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 */ -- cgit v1.2.1