{"id":13123,"url":"https://patchwork.libcamera.org/api/1.1/patches/13123/?format=json","web_url":"https://patchwork.libcamera.org/patch/13123/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210727042750.13525-1-umang.jain@ideasonboard.com>","date":"2021-07-27T04:27:50","name":"[libcamera-devel,v2] utils: ipc: Assign a new gid to proxy worker","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"1990f131edc121caca420f5b4a349c9ad9f1c988","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/1.1/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13123/mbox/","series":[{"id":2280,"url":"https://patchwork.libcamera.org/api/1.1/series/2280/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2280","date":"2021-07-27T04:27:50","name":"[libcamera-devel,v2] utils: ipc: Assign a new gid to proxy worker","version":2,"mbox":"https://patchwork.libcamera.org/series/2280/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13123/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13123/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 3CAC3C322C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Jul 2021 04:28:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EFD44687B7;\n\tTue, 27 Jul 2021 06:27:59 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3EB3E60506\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Jul 2021 06:27:58 +0200 (CEST)","from perceval.ideasonboard.com (unknown [103.251.226.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B96B4EE;\n\tTue, 27 Jul 2021 06:27:56 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Z0WU/dJj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1627360078;\n\tbh=DzAjkO640D7VAVNG3VBWYU5u1YgF8+I248Y+35cEADY=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=Z0WU/dJjbX68o1yhJBWINKvW3ik5kwDjqp0xH6v/RdY/LshvvNxOEP83OOMyVhyo9\n\tvaE2WCTdYVlJyzVB84o6CiqMCSMHMfsiAH0KuGBTkflz8PlbeM9MxtztJAq36ZkpCz\n\twD4fzJP4ww4a9bp+7ia60EsTApr55T8cJ9EDCY90=","From":"Umang Jain <umang.jain@ideasonboard.com>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2] utils: ipc: Assign a new gid to proxy\n\tworker","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Isolated IPAs are forked to a new process by the proxy worker, which\nshares the same process group. This allows the undesired effect that\nthe proxy worker will receive signals such as SIGINT and will be closed\nby a Ctrl-C event before the pipeline handlers have been able to fully\nclean up.\n\nPrevent this signal from being delivered to the proxy worker by moving\nthe process to a new process group, matching the pid of the isolated\nproxy.\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=60\nTested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\nv1 -> v2:\n- Revamp commit message.\n- Fix a typo in `if` condition check.\n---\n .../module_ipa_proxy_worker.cpp.tmpl                 | 12 ++++++++++++\n 1 file changed, 12 insertions(+)","diff":"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\nindex d993e39e..fa529f2c 100644\n--- a/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl\n+++ b/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl\n@@ -207,6 +207,18 @@ int main(int argc, char **argv)\n \t\treturn EXIT_FAILURE;\n \t}\n \n+\t/*\n+\t * Shutdown of proxy worker can be preempt by events like\n+\t * SIGINT/SIGTERM, even before the pipeline handler can request\n+\t * shutdown. Hence, assign a new gid to prevent signals on the\n+\t * application being delivered to the proxy.\n+\t */\n+\tif (setpgid(0, 0) < 0) {\n+\t\tint err = errno;\n+\t\tLOG({{proxy_worker_name}}, Warning)\n+\t\t\t<< \"Failed to set new gid: \" << strerror(err);\n+\t}\n+\n \t{{proxy_worker_name}} proxyWorker;\n \tint ret = proxyWorker.init(ipam, fd);\n \tif (ret < 0) {\n","prefixes":["libcamera-devel","v2"]}