From patchwork Tue Mar 25 18:08:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 23021 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by patchwork.libcamera.org (Postfix) with ESMTPS id 23F55C3213 for ; Tue, 25 Mar 2025 19:20:48 +0000 (UTC) Received: from pendragon.ideasonboard.com (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D2A88353 for ; Tue, 25 Mar 2025 20:19:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742930340; bh=Bk0LKNGS3OO3AGvVk9f5L3HGSQ7+H2GMRKWV09sYKy0=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Resent-From:Resent-To:From; b=bL/mrVxa2uJCmh1BvP8qQOQhBh+Sm0ZdVXRS5s9gWpSD/3bSDKCCoGkHIk77t7+KN FeF/WDYoM+ZtKapemQEbqdv8awxQHSLyOTayWOwaUH7pxCtVHkjSTrgdpxOZRf8xjC xLyhrzBZtbzYJxGnDeg457MjPCUcB4evAFmL3XZo= Delivered-To: kbingham@ideasonboard.com Received: from perceval.ideasonboard.com by perceval.ideasonboard.com with LMTP id KJMRAcrw4mfsuS8A4E0KoQ (envelope-from ) for ; Tue, 25 Mar 2025 19:07:06 +0100 Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by perceval.ideasonboard.com (Postfix) with ESMTPS id D6784353; Tue, 25 Mar 2025 19:07:05 +0100 (CET) Authentication-Results: perceval.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.a=rsa-sha256 header.s=mail header.b=q0xWf3ZL; dkim-atps=neutral Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0733268964; Tue, 25 Mar 2025 19:08:51 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="q0xWf3ZL"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 661F4600EB for ; Tue, 25 Mar 2025 19:08:44 +0100 (CET) Received: from pb-laptop.local (185.221.143.221.nat.pool.zt.hu [185.221.143.221]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CF98782E for ; Tue, 25 Mar 2025 19:06:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742926017; bh=JYVrXzg3/6kpyzn1pqSQm7ylA7r/8ZaMlbV173Qo9PM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=q0xWf3ZLw/fcU4dXsXy/f40AatEmLGGQxaaWGmj0IJXch8X/YGoOBDmuccl6Aytgt tjbAA5KZNVpJv4i32KwUg/que39OxsJlrvTN2olRoJoui7u8hwvTnCTkNWOhmfcjvJ lkHw8CJtwbsh/6jy5VL0PRdB20PrAwOPERvwwZok= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v3 3/9] libcamera: process: Use `pid_` member to decide if running Date: Tue, 25 Mar 2025 19:08:15 +0100 Message-ID: <20250325180821.1456154-4-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250325180821.1456154-1-barnabas.pocze@ideasonboard.com> References: <20250325180821.1456154-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 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" X-TUID: QYN3u8HQInw6 Resent-From: Kieran Bingham Resent-To: parsemail@patchwork.libcamera.org Instead of using a separate member variable, use `pid_ > 0` to determine if the process is still running. Previously the value of `pid_` was not reset to -1 when the process terminated, but since it is only meaningful while the process is running, reset it to -1 in `Process::died()`. Neither `pid_` nor `running_` are exposed, so this change has no effect on the public interface or observable behaviour. Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart --- include/libcamera/internal/process.h | 1 - src/libcamera/process.cpp | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/libcamera/internal/process.h b/include/libcamera/internal/process.h index 58e3e41ce..030a1e66e 100644 --- a/include/libcamera/internal/process.h +++ b/include/libcamera/internal/process.h @@ -49,7 +49,6 @@ private: void died(int wstatus); pid_t pid_; - bool running_; enum ExitStatus exitStatus_; int exitCode_; diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp index 567b878d4..aa9e8f519 100644 --- a/src/libcamera/process.cpp +++ b/src/libcamera/process.cpp @@ -208,7 +208,7 @@ const struct sigaction &ProcessManager::oldsa() const */ Process::Process() - : pid_(-1), running_(false), exitStatus_(NotExited), exitCode_(0) + : pid_(-1), exitStatus_(NotExited), exitCode_(0) { } @@ -240,7 +240,7 @@ int Process::start(const std::string &path, { int ret; - if (running_) + if (pid_ > 0) return 0; int childPid = fork(); @@ -252,8 +252,6 @@ int Process::start(const std::string &path, pid_ = childPid; ProcessManager::instance()->registerProcess(this); - running_ = true; - return 0; } else { if (isolate()) @@ -327,7 +325,7 @@ int Process::isolate() */ void Process::died(int wstatus) { - running_ = false; + pid_ = -1; exitStatus_ = WIFEXITED(wstatus) ? NormalExit : SignalExit; exitCode_ = exitStatus_ == NormalExit ? WEXITSTATUS(wstatus) : -1;