Show a patch.

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

{
    "id": 23453,
    "url": "https://patchwork.libcamera.org/api/patches/23453/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/23453/",
    "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": "<20250527155615.560463-3-julien.vuillaumier@nxp.com>",
    "date": "2025-05-27T15:56:15",
    "name": "[v4,2/2] libcamera: process: Pass stderr and reserve stdin and stdout fds",
    "commit_ref": "5b7c83d8ccd45f5ff533e6bed2001260c765dbb9",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "1fbe259c354b7cdae2d92a0a8b948412b66497e3",
    "submitter": {
        "id": 190,
        "url": "https://patchwork.libcamera.org/api/people/190/?format=api",
        "name": "Julien Vuillaumier",
        "email": "julien.vuillaumier@nxp.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/23453/mbox/",
    "series": [
        {
            "id": 5198,
            "url": "https://patchwork.libcamera.org/api/series/5198/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5198",
            "date": "2025-05-27T15:56:13",
            "name": "libcamera: process: Pass stderr and reserve stdin and stdout fds",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/5198/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/23453/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/23453/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 B39A1C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 May 2025 15:57:19 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6DD3668DA5;\n\tTue, 27 May 2025 17:57:19 +0200 (CEST)",
            "from DU2PR03CU002.outbound.protection.outlook.com\n\t(mail-northeuropeazlp170110003.outbound.protection.outlook.com\n\t[IPv6:2a01:111:f403:c200::3])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9EAFF68D94\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 May 2025 17:57:17 +0200 (CEST)",
            "from AM9PR04MB8147.eurprd04.prod.outlook.com\n\t(2603:10a6:20b:3e0::22)\n\tby AS8PR04MB8499.eurprd04.prod.outlook.com (2603:10a6:20b:342::15)\n\twith Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8769.29;\n\tTue, 27 May 2025 15:57:16 +0000",
            "from AM9PR04MB8147.eurprd04.prod.outlook.com\n\t([fe80::eace:e980:28a4:ef8a]) by\n\tAM9PR04MB8147.eurprd04.prod.outlook.com\n\t([fe80::eace:e980:28a4:ef8a%7]) with mapi id 15.20.8722.027;\n\tTue, 27 May 2025 15:57:16 +0000"
        ],
        "Authentication-Results": [
            "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=nxp.com header.i=@nxp.com header.b=\"RecLk4GK\";\n\tdkim-atps=neutral",
            "dkim=none (message not signed)\n\theader.d=none;dmarc=none action=none header.from=nxp.com;"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n\tb=aSZL+JOWAasdA1/MxBI3iT4aobqdaWtci4+qnhnkftDAwkMbcBBzICdKtfBW3VpNbJHWdq2viYXGTXujAUV9wy8Iic8PiMF4O64+zXvLuGmC2lpWk0cjOiY8+1GaSOTNNpg7pSLBaBehVR68YkcUght3NSjVUdNmX4cSYkRwHg/pN48HYzW36jcpDXQTC4bc1VhjXcpFJ0G3AHvPs8gt8rKz0h0s+gY4BM+YW8fh3gBT/eiV0p+CkvL3UEUkF90tIGD4dNmpSxHoPogCCPsgo4Gu7K5kuPb3baH6VFCgQQllEhBMdhvesldweisAuLbVYO4zodOsrQA+7Of/05Z4Eg==",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n\ts=arcselector10001;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n\tbh=76OcfOe2+3qaMfVCbJSFj5zGUnpKmw24YivdielJyOE=;\n\tb=HieEDuIIwlGsV0doYTnMTVwkwSLBwMKEk6XVJ85+WuW3SINIxEDbpklAcQ0ljdyH9eVe9hxMVc/LjZ2XKxfkPGal6KHTyUCVfqKw0Oxmnm4ZbkyzSN8um6hOTP114E2k6EYZtVxLi45Smlr61vCoeIQIeZ9cJ30ke7u0chsMspDUuSXTa421wLmOtyzilyiMuugxRPFE/XGzXAShPyz+/m0dfAEW9e2mAY/LgUyG70MowXWZ8Nk7mfjzQYVYhf2N4t+SNWogpithp4x9zxCjgKD1mYEG28vBCsUhoZxdSEzzq/bW9Eb+wfGGts2v3YbaI+/O0epKD1EPi7siY268RA==",
        "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass\n\tsmtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com;\n\tdkim=pass header.d=nxp.com; arc=none",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n\tbh=76OcfOe2+3qaMfVCbJSFj5zGUnpKmw24YivdielJyOE=;\n\tb=RecLk4GKRdXPYQunr3KCsjURDNUTXJbqOc4Mx5clz/BPHYr4Rp6X3qjge50fH9doATPRWibBgILP82a15fFc6x/URNWfgrvAaYAxOpAChDHyMp5NFkvH0rwJLW0ua8vpME2IgwtHTYLwAe7WeSONm3FeqfNqB2UeAtlFD04xh7ppadXvnk3bAjxAm+SCCDwwWUHOhbVH5nWgcM1WOTVEwzMYjP45fcOfhQAG6ZwEc9E5r9ikzkPZkp3/3kFRPAk8eZP4JpbOqiEKQ30pfsMYgtrK41R5jxhES8hfVuhu75Ef/ITc+Om7hZPFky/q9VUSsEvKo0Ck4bllCLvSZD4TNQ==",
        "From": "Julien Vuillaumier <julien.vuillaumier@nxp.com>",
        "To": "libcamera-devel@lists.libcamera.org, barnabas.pocze@ideasonboard.com,\n\tpaul.elder@ideasonboard.com",
        "Cc": "Julien Vuillaumier <julien.vuillaumier@nxp.com>",
        "Subject": "[PATCH v4 2/2] libcamera: process: Pass stderr and reserve stdin and\n\tstdout fds",
        "Date": "Tue, 27 May 2025 17:56:15 +0200",
        "Message-Id": "<20250527155615.560463-3-julien.vuillaumier@nxp.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20250527155615.560463-1-julien.vuillaumier@nxp.com>",
        "References": "<20250527155615.560463-1-julien.vuillaumier@nxp.com>",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-ClientProxiedBy": "AS4PR09CA0017.eurprd09.prod.outlook.com\n\t(2603:10a6:20b:5d4::11) To AM9PR04MB8147.eurprd04.prod.outlook.com\n\t(2603:10a6:20b:3e0::22)",
        "MIME-Version": "1.0",
        "X-MS-PublicTrafficType": "Email",
        "X-MS-TrafficTypeDiagnostic": "AM9PR04MB8147:EE_|AS8PR04MB8499:EE_",
        "X-MS-Office365-Filtering-Correlation-Id": "8b575084-e1dc-4cc2-4416-08dd9d372743",
        "X-MS-Exchange-SenderADCheck": "1",
        "X-MS-Exchange-AntiSpam-Relay": "0",
        "X-Microsoft-Antispam": "BCL:0;\n\tARA:13230040|1800799024|366016|376014|52116014|38350700014; ",
        "X-Microsoft-Antispam-Message-Info": "DwYZLJOmmE1b7P/e1UgvKKItlgN19MQRBay6lPvwZH+Hfyu1vWshOqt+eFxRjAMLYpBhAYik1JmkKPQftujwQBHkOJj+6EPVN/e0rEbZr0UcCc14EYOqksPXJqp8Fvafu6y2ht/QEidQNktCseCX1Z/Lsf4kwVLJysxYUzEp/OI2Aj+sGT8o1kYKoFKNMWQKKvGsv4Z9Cj2NCbXkGC0brHhVclQnMouPa9ZLwcsWN59AIB9jCe7y3J2sDXerLy2h2AIyd3fXU4RUQBsB9ZPzhkEUSZOacIroupexVu2pIRxZSDShj6yulLKNwW+ArTZZ9F3loO2l/QVQWS3w16ocPqPJtte7cjbPAioa9+/8O3WufzSyjdMwiHMiANRbPjyKmQBFt38h83Q+T9eeXKXdMkBGLzs35jH9PbGczyLieyXeVVu8wdLO9M3L7lrINhCChHOUoCp5hgdnpVMgrf4Y9PPFesv4BnmiBDsJ3G8VjqXCh9+SU/1S7AakcI4HKsx4N3G+M84YC4NXKyDYzNypmzoCVe8fYDYqlCR11W1Ra/HW5VfE2ZP34H9QgpP2GJj91hLksrOmtUVbjkMGTLratlyEA3agnkvlsA2TrlQ+2dbZ8clyN2mF2LnN99bq7kum40symoBhrMV0xDeE4hSU4Ph0rmb5Xw+H1jf1P72GrkYHUQv7ZizjnSR+g5iahkxoUeig8+akAkHdI1/CKM/U0Z5pZBGQYbaceeG4s3L0nRxGRCwefXqtIyQQCD/OiBagGw46nEMYU3+6xMhPEbBs36xqvfHTDHe809ZW3ChMMmpN3dO1dsKbzc8IV8KIy0pn7JR1aOv5yFDnJIJ9mMzcR7qRboZMR0ImchbM7aQ90IPi8EyrRRLukkBBG6wwnf46QEQ9GngPdRXobCqvSu7upXmgQG94iGqRBQrYNdPu3npruofLfCgWlVBjV6DQenIkXD58qZY5m187HVOPGYCY0T9+H8EUv6E4BYAwOJlq/u9bobKBY5uv2xxJTBteOmZD3aHbvAzpZjSHvi81MhQ2ssI/3cjcEeUOKwSDF798LmuT+bh5aDB47sh4BcYS4mallu7x+IdSAyuokA+azB3WP7bJaL6MSrfJn7tiUA8DtGNxFeUA+pJ/MCdQec/khi2oiLpsDtHkmDupvuta0Y4TfkbLuYKYCeL4e9z3eeoA9dxP8nxNAn8qrznJjqdckTFKeSBwLHN84M5KFL7XfrDIMHYyjjzmq1zJyON4ZucEyfvrzGAYhF7Zhp+KHqS0Y1bEgKt+LtOhsTEDWpHMn0gO5lBifYVCJ/bySDvwOiyda6jL/TkjpwiTj4VZPEq95g64L/hKT3oFQNM74zgIOW7Qkgm0g8FLNiYq7E4zzgMCAbVPhk/f+uNz2HrZ93BrLybL8cSJ+rQTm6SYFFkibCpKdKbc/N1JhyTVwQ54SlWHQ2VV5flmqN4ecqXUBFhIeuVrRjucHDCqzOL7eXyy+TbTGA==",
        "X-Forefront-Antispam-Report": "CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;\n\tIPV:NLI; SFV:NSPM; H:AM9PR04MB8147.eurprd04.prod.outlook.com; PTR:;\n\tCAT:NONE; \n\tSFS:(13230040)(1800799024)(366016)(376014)(52116014)(38350700014);\n\tDIR:OUT; SFP:1101; ",
        "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1",
        "X-MS-Exchange-AntiSpam-MessageData-0": "uovK70nJ2q2m8X9qpjzeOPpL6XZYpQANVEOGAlEZQoX+gid3Pch8WT/slyeZeFxC3zNzIQ9voCv4AnQ1bKFuYZK+gxOyycWHooaADbaXv5s/8tInnRx1Dvwunmk1w8SQuiUtQTnklRQxizvuFngAY8iIkOvlQ5R//fT6wNkpa+/v5B7KKDLxZkVyZOB+uAl/1tGTWj3/hY+ZLIE44pPkSi+fEzRcysnkEDU3oSLlX3szVSzW/kdVFvJPvIDBSUWs0uCpLoAFG1CAw7eFCaEp2F3awM2W6QhFBG406tijFw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59f5yLb4Ll+NjzX9UPko4ErlFLbLq+lLoXRg8eXgTqo99vRWQzMWzWksAKWhmt098ucG7beI1WVXcyAL/7TeA+BoKNrhjKg5Gbtgd2NOE/v9KPonClrVgCGuNfD4ocwsnvzBOGkJ55l6FW7Y0kCnEkfurGv3PnRuUI7aEMCSVU4xk58A/jjhDp6XOxCcHT20kfGuL39tyNnruUkPdDp1Ex+Twr9MWEw4ttE1selYG8jnHdNtqB/Hg==",
        "X-OriginatorOrg": "nxp.com",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "8b575084-e1dc-4cc2-4416-08dd9d372743",
        "X-MS-Exchange-CrossTenant-AuthSource": "AM9PR04MB8147.eurprd04.prod.outlook.com",
        "X-MS-Exchange-CrossTenant-AuthAs": "Internal",
        "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "27 May 2025 15:57:16.5583\n\t(UTC)",
        "X-MS-Exchange-CrossTenant-FromEntityHeader": "Hosted",
        "X-MS-Exchange-CrossTenant-Id": "686ea1d3-bc2b-4c6f-a92c-d99c5c301635",
        "X-MS-Exchange-CrossTenant-MailboxType": "HOSTED",
        "X-MS-Exchange-CrossTenant-UserPrincipalName": "By7bCXVpoKK97m/37mGgRrB9uxTSOG7PenB64AAOlCLu7Ij5fwxVQKTn7gzKMtXwvg2KrnlDLXxDbmdgy47a5t/xyAubONwbN3DhxNFpJgI=",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "AS8PR04MB8499",
        "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": "When a child process is started from Process::start(), the file\ndescriptors inherited from the parent process are closed, except\nthe ones explicitly listed in the fds[] argument.\n\nOne issue is that the file descriptors for stdin, stdout and stderr\nbeing closed, the subsequent file descriptors created by the child\nprocess will reuse the values 0, 1 and 2 that are now available.\nThus, usage of printf(), assert() or alike may direct its output\nto the new resource bound to one of these reused file descriptors.\nThe other issue is that the child process can no longer log on\nthe console because stderr has been closed.\n\nTo address the 2 issues, Process:start() is amended as below:\n- Child process inherits from parent's stderr fd in order to share\nthe same logging descriptor\n- Child process stdin, stdout and stderr fds are bound to /dev/null\nif not inherited from parent. That is to prevent those descriptors\nto be reused for any other resource, that could be corrupted by\nthe presence of printf(), assert() or alike.\n\nSigned-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n src/libcamera/process.cpp | 16 +++++++++++++++-\n 1 file changed, 15 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp\nindex 7f3a6518..d836fb07 100644\n--- a/src/libcamera/process.cpp\n+++ b/src/libcamera/process.cpp\n@@ -259,7 +259,21 @@ int Process::start(const std::string &path,\n \t\tif (isolate())\n \t\t\t_exit(EXIT_FAILURE);\n \n-\t\tcloseAllFdsExcept(fds);\n+\t\tstd::vector<int> v(fds);\n+\t\tv.push_back(STDERR_FILENO);\n+\t\tcloseAllFdsExcept(v);\n+\n+\t\tconst auto tryDevNullLowestFd = [](int expected, int oflag) {\n+\t\t\tint fd = open(\"/dev/null\", oflag);\n+\t\t\tif (fd < 0)\n+\t\t\t\t_exit(EXIT_FAILURE);\n+\t\t\tif (fd != expected)\n+\t\t\t\tclose(fd);\n+\t\t};\n+\n+\t\ttryDevNullLowestFd(STDIN_FILENO, O_RDONLY);\n+\t\ttryDevNullLowestFd(STDOUT_FILENO, O_WRONLY);\n+\t\ttryDevNullLowestFd(STDERR_FILENO, O_WRONLY);\n \n \t\tconst char *file = utils::secure_getenv(\"LIBCAMERA_LOG_FILE\");\n \t\tif (file && strcmp(file, \"syslog\"))\n",
    "prefixes": [
        "v4",
        "2/2"
    ]
}