Show a patch.

GET /api/patches/23994/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 23994,
    "url": "https://patchwork.libcamera.org/api/patches/23994/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/23994/",
    "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": "<20250728113641.238256-5-barnabas.pocze@ideasonboard.com>",
    "date": "2025-07-28T11:36:39",
    "name": "[v6,4/6] libcamera: process: Move `closeAllFdsExcept()`",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "f1cb710d30390c335f776222b46ffdff276ef7ef",
    "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/23994/mbox/",
    "series": [
        {
            "id": 5342,
            "url": "https://patchwork.libcamera.org/api/series/5342/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5342",
            "date": "2025-07-28T11:36:35",
            "name": "libcamera: process: Remove `ProcessManager` singleton",
            "version": 6,
            "mbox": "https://patchwork.libcamera.org/series/5342/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/23994/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/23994/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 E2E37C332B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Jul 2025 11:37:00 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8AF1F69164;\n\tMon, 28 Jul 2025 13:36:56 +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 A908169159\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jul 2025 13:36:46 +0200 (CEST)",
            "from pb-laptop.local (185.221.140.39.nat.pool.zt.hu\n\t[185.221.140.39])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ABC36C72;\n\tMon, 28 Jul 2025 13:36:04 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"QXFEP342\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753702564;\n\tbh=4/BE+YfFh43F4ZcvYJCKXIV+ljfVNpilAlG1SR/dzaE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=QXFEP342tao8iA4ExjIKNa3JUgiwp+DgBZG1sOMWJx3ITLp1eHxXxIJOUI2oUhof/\n\td1Z5Eqy8my6NWE/nqgp46eITFfQ0mREvYvIVvJ25YA6mhoFSG7Cwb4tsyK4aW4KgCj\n\tPmuG0BHTNEGN7yoRwfVCwR2j7aejVOXTqMe/9Xx4=",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>",
        "Subject": "[PATCH v6 4/6] libcamera: process: Move `closeAllFdsExcept()`",
        "Date": "Mon, 28 Jul 2025 13:36:39 +0200",
        "Message-ID": "<20250728113641.238256-5-barnabas.pocze@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.50.1",
        "In-Reply-To": "<20250728113641.238256-1-barnabas.pocze@ideasonboard.com>",
        "References": "<20250728113641.238256-1-barnabas.pocze@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "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": "Remove `closeAllFdsExcept()` from the `Process` class and have it as a\nlocal function since it is not needed \"outside\" and does not depend on\nany part of the `Process` class.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/internal/process.h |  1 -\n src/libcamera/process.cpp            | 54 ++++++++++++++--------------\n 2 files changed, 27 insertions(+), 28 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/process.h b/include/libcamera/internal/process.h\nindex 4ab846b24..e55d11fa3 100644\n--- a/include/libcamera/internal/process.h\n+++ b/include/libcamera/internal/process.h\n@@ -45,7 +45,6 @@ public:\n private:\n \tLIBCAMERA_DISABLE_COPY_AND_MOVE(Process)\n \n-\tvoid closeAllFdsExcept(std::vector<int> v);\n \tint isolate();\n \tvoid died(int wstatus);\n \ndiff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp\nindex 5193386ce..4b87c5591 100644\n--- a/src/libcamera/process.cpp\n+++ b/src/libcamera/process.cpp\n@@ -63,6 +63,33 @@ void sigact(int signal, siginfo_t *info, void *ucontext)\n \t}\n }\n \n+void closeAllFdsExcept(std::vector<int> v)\n+{\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 } /* namespace */\n \n void ProcessManager::sighandler()\n@@ -296,33 +323,6 @@ int Process::start(const std::string &path,\n \t}\n }\n \n-void Process::closeAllFdsExcept(std::vector<int> v)\n-{\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": [
        "v6",
        "4/6"
    ]
}