summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYou-Sheng Yang <vicamo.yang@canonical.com>2020-07-25 20:24:40 +0800
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-07-27 13:53:53 +0300
commit774f0d1b9b59f5a779d0bf257b365f307cf191f8 (patch)
tree9a189754702b2d029e1f8be90c292ed53d188aa9
parent256845d5b7edf97b77a99257d18e53d3453bc534 (diff)
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 <vicamo.yang@canonical.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--src/libcamera/process.cpp3
1 files changed, 2 insertions, 1 deletions
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 */