Show a patch.

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

{
    "id": 18463,
    "url": "https://patchwork.libcamera.org/api/patches/18463/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18463/",
    "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": "<20230326100155.7532-1-laurent.pinchart@ideasonboard.com>",
    "date": "2023-03-26T10:01:55",
    "name": "[libcamera-devel] libcamera: Open files with O_CLOEXEC",
    "commit_ref": "436b38fd89fe4324d2342084ef477a7a8809a001",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "cf5530f0b36a3bb58a8b331c8b831af14bb42597",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18463/mbox/",
    "series": [
        {
            "id": 3817,
            "url": "https://patchwork.libcamera.org/api/series/3817/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3817",
            "date": "2023-03-26T10:01:55",
            "name": "[libcamera-devel] libcamera: Open files with O_CLOEXEC",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3817/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18463/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18463/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 DF619BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 26 Mar 2023 10:01:52 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2CE1F626E2;\n\tSun, 26 Mar 2023 12:01:52 +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 06670626DA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 26 Mar 2023 12:01:50 +0200 (CEST)",
            "from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi\n\t[213.243.189.158])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4F1C7741\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 26 Mar 2023 12:01:49 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1679824912;\n\tbh=wWT3AxhRArawgpvSdgRo4L7ABYeN0sOitNgPnWxb+8g=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=Ssf9U2zhnUqb8CvoWUkwyP/+f3cnAX27nU6m6Ko20bNYiCQyXEW5A3HbJH6G1Hq/D\n\tkGGXIcOc2sYHwhbESOYeILh57xAewPeYPZN5YDjA2P5ut2PhDU01Neh/8iBRTADyUR\n\tPfVVHOtrQ/BJpq0WJ4cT1Nzfm17felFUf3MHhFI4rXMa7iAJpscz80wdw7K2q8cXJa\n\tzaMK+lGWiL0Qeensog9ymIOD9dxte6MJT+pIeXdrephgN8b1qQ4+Y0rCOp03xqQ8GO\n\tfqR9j8eo7yhBNKY9BK8aqlU/nbQHXHJzICJ3L2oXgre9qe8NO+j2CNHy0MC5rHyXyT\n\tfIrivvBC5dojA==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1679824909;\n\tbh=wWT3AxhRArawgpvSdgRo4L7ABYeN0sOitNgPnWxb+8g=;\n\th=From:To:Subject:Date:From;\n\tb=nnMBwdhR6xF1jj3RoLDQZxBS8g7yhaawoBrlnjJ51FMt7trqOCe4Pt3RurBMFByeL\n\tzLbDuDD7d8u/c8anKulzKQzlHcZHsaEZiy/rlk5DkpRu5pRxIt494Jtlv9Hip7tP62\n\tkn23rBBkAlGXrKzokWWWQXTdaFyNkrm/a/9LI40Q="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"nnMBwdhR\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun, 26 Mar 2023 13:01:55 +0300",
        "Message-Id": "<20230326100155.7532-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.39.2",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] libcamera: Open files with O_CLOEXEC",
        "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>",
        "From": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Files opened internally in libcamera without the O_CLOEXEC file will\nremain open upon a call to one of the exec(3) functions. As exec()\ndoesn't destroy local or global objects, this can lead to various side\neffects. Avoid this by opening file descriptors with O_CLOEXEC for all\ninternal files.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/vimc/vimc.cpp                            | 2 +-\n src/libcamera/base/file.cpp                      | 5 ++++-\n src/libcamera/media_device.cpp                   | 2 +-\n src/libcamera/pipeline/raspberrypi/dma_heaps.cpp | 2 +-\n 4 files changed, 7 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp\nindex d5fabaf13ec6..2c255778990a 100644\n--- a/src/ipa/vimc/vimc.cpp\n+++ b/src/ipa/vimc/vimc.cpp\n@@ -168,7 +168,7 @@ void IPAVimc::initTrace()\n \tif (ret)\n \t\treturn;\n \n-\tret = ::open(ipa::vimc::VimcIPAFIFOPath.c_str(), O_WRONLY);\n+\tret = ::open(ipa::vimc::VimcIPAFIFOPath.c_str(), O_WRONLY | O_CLOEXEC);\n \tif (ret < 0) {\n \t\tret = errno;\n \t\tLOG(IPAVimc, Error) << \"Failed to open vimc IPA test FIFO: \"\ndiff --git a/src/libcamera/base/file.cpp b/src/libcamera/base/file.cpp\nindex fb3e276d6ccd..d1ab1aa57462 100644\n--- a/src/libcamera/base/file.cpp\n+++ b/src/libcamera/base/file.cpp\n@@ -163,6 +163,9 @@ bool File::exists() const\n  * attempt to create the file with initial permissions set to 0666 (modified by\n  * the process' umask).\n  *\n+ * The file is opened with the O_CLOEXEC flag, and will be closed automatically\n+ * when a new binary is executed with one of the exec(3) functions.\n+ *\n  * The error() status is updated.\n  *\n  * \\return True on success, false otherwise\n@@ -178,7 +181,7 @@ bool File::open(File::OpenMode mode)\n \tif (mode & OpenModeFlag::WriteOnly)\n \t\tflags |= O_CREAT;\n \n-\tfd_ = UniqueFD(::open(name_.c_str(), flags, 0666));\n+\tfd_ = UniqueFD(::open(name_.c_str(), flags | O_CLOEXEC, 0666));\n \tif (!fd_.isValid()) {\n \t\terror_ = -errno;\n \t\treturn false;\ndiff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex 52c8e66e9e99..2949816b4a64 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -477,7 +477,7 @@ int MediaDevice::open()\n \t\treturn -EBUSY;\n \t}\n \n-\tfd_ = UniqueFD(::open(deviceNode_.c_str(), O_RDWR));\n+\tfd_ = UniqueFD(::open(deviceNode_.c_str(), O_RDWR | O_CLOEXEC));\n \tif (!fd_.isValid()) {\n \t\tint ret = -errno;\n \t\tLOG(MediaDevice, Error)\ndiff --git a/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp b/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp\nindex 6b644406c90f..317b1fc17161 100644\n--- a/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp\n@@ -37,7 +37,7 @@ namespace RPi {\n DmaHeap::DmaHeap()\n {\n \tfor (const char *name : heapNames) {\n-\t\tint ret = ::open(name, O_RDWR, 0);\n+\t\tint ret = ::open(name, O_RDWR | O_CLOEXEC, 0);\n \t\tif (ret < 0) {\n \t\t\tret = errno;\n \t\t\tLOG(RPI, Debug) << \"Failed to open \" << name << \": \"\n",
    "prefixes": [
        "libcamera-devel"
    ]
}