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

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Jul 27 00:42:06 CEST 2020


Hi You-Shang,

Thank you for the patch.

On Sat, Jul 25, 2020 at 08:24:40PM +0800, You-Sheng Yang wrote:
> 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)`.

Oops. This is embarassing :-)

> Signed-off-by: You-Sheng Yang <vicamo.yang at canonical.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.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 */

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list