Patch Detail
Show a patch.
GET /api/patches/23022/?format=api
{ "id": 23022, "url": "https://patchwork.libcamera.org/api/patches/23022/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23022/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250325180821.1456154-8-barnabas.pocze@ideasonboard.com>", "date": "2025-03-25T18:08:19", "name": "[RFC,v3,7/9] libcamera: process: Move `closeAllFdsExcept()`", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "a648f4105a0c14517a4d5961f0fc2d8ddf240585", "submitter": { "id": 216, "url": "https://patchwork.libcamera.org/api/people/216/?format=api", "name": "Barnabás Pőcze", "email": "barnabas.pocze@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/23022/mbox/", "series": [ { "id": 5079, "url": "https://patchwork.libcamera.org/api/series/5079/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5079", "date": "2025-03-25T18:08:12", "name": "libcamera: process: Remove `ProcessManager` singleton", "version": 3, "mbox": "https://patchwork.libcamera.org/series/5079/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23022/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23022/checks/", "tags": {}, "headers": { "Return-Path": "<kieran.bingham@ideasonboard.com>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": [ "parsemail@patchwork.libcamera.org", "kbingham@ideasonboard.com" ], "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9635EC3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Mar 2025 19:21:14 +0000 (UTC)", "from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net\n\t[86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 508F9353\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Mar 2025 20:19:27 +0100 (CET)", "from perceval.ideasonboard.com\n\tby perceval.ideasonboard.com with LMTP id QN/8JNPw4mcIui8A4E0KoQ\n\t(envelope-from <libcamera-devel-bounces@lists.libcamera.org>)\n\tfor <kbingham@ideasonboard.com>; Tue, 25 Mar 2025 19:07:15 +0100", "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\tby perceval.ideasonboard.com (Postfix) with ESMTPS\n\tid 736B4353;\tTue, 25 Mar 2025 19:07:15 +0100 (CET)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F3C826895D;\n\tTue, 25 Mar 2025 19:09:00 +0100 (CET)", "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 A390468952\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Mar 2025 19:08:47 +0100 (CET)", "from pb-laptop.local (185.221.143.221.nat.pool.zt.hu\n\t[185.221.143.221])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 11223353\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Mar 2025 19:06:59 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1742930367;\n\tbh=+j2mYamSF9tXXw08/WL/JPliWJ6Adi1nuMH7jWWk/CQ=;\n\th=From:To:Subject:Date:In-Reply-To:References:List-Id:\n\tList-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:\n\tResent-From:Resent-To:From;\n\tb=X+SFezx+Hc80w+WNZU/T4mNS1KmJR1ow1o+kPpFxWgb5eh2SPvxYrg2I5o/O/RVpf\n\tIflm7O+tnShF60RreyYfG+CJWXpgrKO7VXdQQgapmZMTbjEDKYOpkOfppvgTJw8cbs\n\toTLQhAJxIwgjV/+r7ZVR46TrXZlm6FquGWkSF/Yc=", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1742926020;\n\tbh=hkTcXpSyWx7kGcQfaYLCqweQCjn31N2EjC6G98vUfGM=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=coBrJMS29P3vVByeAzCOQCjifZ3KPsClA0eUbEZhLV28qyHX2JXUODyLdKkZX+3w0\n\tuXdSOPicCzFYl0hhW25Ut2ksQHBmBSaAp8N3OGJhFfas2E1/6scCxkvcNzf0XBXV5n\n\tSNjnWv79wh+liHwisrn6HAGpBsVjm0rSd6X8xlWM=" ], "Authentication-Results": [ "perceval.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.a=rsa-sha256 header.s=mail header.b=coBrJMS2; dkim-atps=neutral", "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"coBrJMS2\";\tdkim-atps=neutral" ], "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[RFC PATCH v3 7/9] libcamera: process: Move `closeAllFdsExcept()`", "Date": "Tue, 25 Mar 2025 19:08:19 +0100", "Message-ID": "<20250325180821.1456154-8-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", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "quoted-printable", "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>", "X-TUID": "LfNPeoJK49Vh", "Resent-From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "Resent-To": "parsemail@patchwork.libcamera.org" }, "content": "Remove `closeAllFdsExcept()` from the `Process` class and have\nit as a local function since it is no needed \"outside\" and does\nnot depend on any part of the `Process` class.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n include/libcamera/internal/process.h | 1 -\n src/libcamera/process.cpp | 56 ++++++++++++++--------------\n 2 files changed, 28 insertions(+), 29 deletions(-)", "diff": "diff --git a/include/libcamera/internal/process.h b/include/libcamera/internal/process.h\nindex e4f5bb979..14391d60a 100644\n--- a/include/libcamera/internal/process.h\n+++ b/include/libcamera/internal/process.h\n@@ -44,7 +44,6 @@ public:\n private:\n \tLIBCAMERA_DISABLE_COPY_AND_MOVE(Process)\n \n-\tvoid closeAllFdsExcept(Span<const int> fds);\n \tint isolate();\n \tvoid died(int wstatus);\n \ndiff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp\nindex 5603dc903..01503e485 100644\n--- a/src/libcamera/process.cpp\n+++ b/src/libcamera/process.cpp\n@@ -63,6 +63,34 @@ void sigact(int signal, siginfo_t *info, void *ucontext)\n \t}\n }\n \n+void closeAllFdsExcept(Span<const int> fds)\n+{\n+\tstd::vector<int> v(fds.begin(), fds.end());\n+\tstd::sort(v.begin(), v.end());\n+\n+\tASSERT(v.empty() || v.front() >= 0);\n+\n+\tDIR *dir = opendir(\"/proc/self/fd\");\n+\tif (!dir)\n+\t\treturn;\n+\n+\tint dfd = dirfd(dir);\n+\n+\tstruct dirent *ent;\n+\twhile ((ent = readdir(dir)) != nullptr) {\n+\t\tchar *endp;\n+\t\tint fd = strtoul(ent->d_name, &endp, 10);\n+\t\tif (*endp)\n+\t\t\tcontinue;\n+\n+\t\tif (fd >= 0 && fd != dfd &&\n+\t\t !std::binary_search(v.begin(), v.end(), fd))\n+\t\t\tclose(fd);\n+\t}\n+\n+\tclosedir(dir);\n+}\n+\n } /* namespace */\n \n void ProcessManager::sighandler()\n@@ -282,34 +310,6 @@ int Process::start(const std::string &path,\n \t}\n }\n \n-void Process::closeAllFdsExcept(Span<const int> fds)\n-{\n-\tstd::vector<int> v(fds.begin(), fds.end());\n-\tsort(v.begin(), v.end());\n-\n-\tASSERT(v.empty() || v.front() >= 0);\n-\n-\tDIR *dir = opendir(\"/proc/self/fd\");\n-\tif (!dir)\n-\t\treturn;\n-\n-\tint dfd = dirfd(dir);\n-\n-\tstruct dirent *ent;\n-\twhile ((ent = readdir(dir)) != nullptr) {\n-\t\tchar *endp;\n-\t\tint fd = strtoul(ent->d_name, &endp, 10);\n-\t\tif (*endp)\n-\t\t\tcontinue;\n-\n-\t\tif (fd >= 0 && fd != dfd &&\n-\t\t !std::binary_search(v.begin(), v.end(), fd))\n-\t\t\tclose(fd);\n-\t}\n-\n-\tclosedir(dir);\n-}\n-\n int Process::isolate()\n {\n \tint ret = unshare(CLONE_NEWUSER | CLONE_NEWNET);\n", "prefixes": [ "RFC", "v3", "7/9" ] }