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>
This commit is contained in:
You-Sheng Yang
2020-07-25 20:24:40 +08:00
committed by Laurent Pinchart
parent 256845d5b7
commit 774f0d1b9b
+2 -1
View File
@@ -373,7 +373,8 @@ void Process::died(int wstatus)
*/
void Process::kill()
{
::kill(pid_, SIGKILL);
if (pid_ > 0)
::kill(pid_, SIGKILL);
}
} /* namespace libcamera */