From patchwork Tue Jul 27 04:27:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13123 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 3CAC3C322C for ; Tue, 27 Jul 2021 04:28:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EFD44687B7; Tue, 27 Jul 2021 06:27:59 +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="Z0WU/dJj"; 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 3EB3E60506 for ; Tue, 27 Jul 2021 06:27:58 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.156]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B96B4EE; Tue, 27 Jul 2021 06:27:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627360078; bh=DzAjkO640D7VAVNG3VBWYU5u1YgF8+I248Y+35cEADY=; h=From:To:Cc:Subject:Date:From; b=Z0WU/dJjbX68o1yhJBWINKvW3ik5kwDjqp0xH6v/RdY/LshvvNxOEP83OOMyVhyo9 vaE2WCTdYVlJyzVB84o6CiqMCSMHMfsiAH0KuGBTkflz8PlbeM9MxtztJAq36ZkpCz wD4fzJP4ww4a9bp+7ia60EsTApr55T8cJ9EDCY90= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Jul 2021 09:57:50 +0530 Message-Id: <20210727042750.13525-1-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] 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" Isolated IPAs are forked to a new process by the proxy worker, which shares the same process group. This allows the undesired effect that the proxy worker will receive signals such as SIGINT and will be closed by a Ctrl-C event before the pipeline handlers have been able to fully clean up. Prevent this signal from being delivered to the proxy worker by moving the process to a new process group, matching the pid of the isolated proxy. Bug: https://bugs.libcamera.org/show_bug.cgi?id=60 Tested-by: Kieran Bingham Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Umang Jain --- v1 -> v2: - Revamp commit message. - Fix a typo in `if` condition check. --- .../module_ipa_proxy_worker.cpp.tmpl | 12 ++++++++++++ 1 file changed, 12 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..fa529f2c 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,18 @@ int main(int argc, char **argv) return EXIT_FAILURE; } + /* + * Shutdown of proxy worker can be preempt by events like + * SIGINT/SIGTERM, even before the pipeline handler can request + * shutdown. Hence, assign a new gid to prevent signals on the + * application being delivered to the proxy. + */ + if (setpgid(0, 0) < 0) { + int err = errno; + LOG({{proxy_worker_name}}, Warning) + << "Failed to set new gid: " << strerror(err); + } + {{proxy_worker_name}} proxyWorker; int ret = proxyWorker.init(ipam, fd); if (ret < 0) {