From patchwork Mon Jul 26 10:31:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13117 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 88189C322C for ; Mon, 26 Jul 2021 10:31:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0B46D68536; Mon, 26 Jul 2021 12:31:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jT03NINn"; 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 D258068536 for ; Mon, 26 Jul 2021 12:31:33 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.156]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8DED8332; Mon, 26 Jul 2021 12:31:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627295493; bh=KpntycZyjKPX62i1VU+SPBIKw2z6hIN52IU/+5LxhF0=; h=From:To:Cc:Subject:Date:From; b=jT03NINnCVsfkRu+EmN6eFLPRC+zNIYPuTemF5CtTNM0evB0bFlxh5Jl7eIbAZGi5 csV7PkVD71WCp+/fXJ0b607tBy5xXcUwjWShI4wf/+2f/UdfISv214UeD/uV/cdS+n 3DUvfbECs51IFYusJ1B6vX3kRWDxbox1DFmpoK/Q= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Mon, 26 Jul 2021 16:01:26 +0530 Message-Id: <20210726103126.43238-1-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] utils: ipc: Assign a new gid to proxy worker 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" Doing so, handles the situation where the proxy worker has been shutdown by SIGINT/SIGTERM preemptively, before the pipeline handler got a chance to cleanup nicely. Bug: https://bugs.libcamera.org/show_bug.cgi?id=60 Signed-off-by: Umang Jain Tested-by: Kieran Bingham Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Paul Elder --- .../module_ipa_proxy_worker.cpp.tmpl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl b/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl index d993e39e..32ac3869 100644 --- a/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl +++ b/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl @@ -207,6 +207,16 @@ int main(int argc, char **argv) return EXIT_FAILURE; } + /* + * Shutdown of proxy worker can be preemptive by events like + * SIGINT/SIGTERM, even before the pipeline handler can request + * shutdown. Hence, assign a new gid to handle these situations. + */ + if (setpgid(0, 0) < -1) { + LOG({{proxy_worker_name}}, Warning) + << "Failed to set new gid: " << strerror(errno); + } + {{proxy_worker_name}} proxyWorker; int ret = proxyWorker.init(ipam, fd); if (ret < 0) {