From patchwork Sat Jul 25 12:24:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 8997 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 44157BD878 for ; Sat, 25 Jul 2020 13:03:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1ED9061384; Sat, 25 Jul 2020 15:03:28 +0200 (CEST) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A4F5461223 for ; Sat, 25 Jul 2020 14:24:49 +0200 (CEST) Received: by mail-pl1-f195.google.com with SMTP id f7so1014111pln.13 for ; Sat, 25 Jul 2020 05:24:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ScdbYZrkdaR2xP65QRge/jc73B6q7JflgJPqSB4oq78=; b=gnFPC/dku6vG3liWiSe5vbazzYY4kjHgvIQG/gR2iuIaINqwwVTZqmKxfW/1JOZmIu wt15WlgUn1R/qmgV9BHMtCr0dQHpABnqJAWwLM9XwVAQDKERIO65pGFDNkus64Er4Wfc GHJMth/+uGNrUV4tzyqJQ75lZrCqI/R1Cqic3RUIA6rsrIsUcgsxzIf0R9YqBiCp3QVF DRzACM85SAD7f9RMmdbH9Z0liJcpi+6Ph/8sBKizU6UPHZqHgh2zfbxfpJunAw0ZAAcD WHUsc+8UqOVBroNOO337BR05onmgyDltRm8+vWX7mQRefpOLLdcy7QRKMWDsKiUxb9xx dQpA== X-Gm-Message-State: AOAM531WD7VYNXqL7ZWT234nm4tRAqkldIkGwuJqS+9/6t1f4PG6Rh/w tq6xBwhDcqtK5UAKtQWk9IGo+vkQw/4= X-Google-Smtp-Source: ABdhPJy3F4tTVMmiIgPo8q+gg8ebqtv9eUu0GEnbjRVSYVUffc4JbGQJoPG9ScF0xjbpIV3NdYNFOA== X-Received: by 2002:a17:90a:c68e:: with SMTP id n14mr9507183pjt.182.1595679887714; Sat, 25 Jul 2020 05:24:47 -0700 (PDT) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id n25sm9631393pff.51.2020.07.25.05.24.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jul 2020 05:24:46 -0700 (PDT) From: You-Sheng Yang To: libcamera-devel@lists.libcamera.org Date: Sat, 25 Jul 2020 20:24:40 +0800 Message-Id: <20200725122442.1679820-2-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200725122442.1679820-1-vicamo.yang@canonical.com> References: <20200725122442.1679820-1-vicamo.yang@canonical.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 25 Jul 2020 15:03:26 +0200 Subject: [libcamera-devel] [PATCH 1/3] libcamera: process: fix killing innocent processes unexpectedly X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Kieran Bingham --- 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 */