[{"id":36405,"web_url":"https://patchwork.libcamera.org/comment/36405/","msgid":"<176123194494.2256500.12551924303498622982@ping.linuxembedded.co.uk>","date":"2025-10-23T15:05:44","subject":"Re: [PATCH v1] libcamera: base: {Unique,\n\tShared}FD: Warn if closing fails","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2025-10-23 15:59:06)\n> If the contained file descriptor cannot be successfully closed,\n> that is usually a sign of a more serious invariant violation,\n> which deserves attention, so report those cases.\n\nOhh has this happened for you?\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> ---\n>  src/libcamera/base/shared_fd.cpp | 7 +++++--\n>  src/libcamera/base/unique_fd.cpp | 8 ++++++--\n>  2 files changed, 11 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/libcamera/base/shared_fd.cpp b/src/libcamera/base/shared_fd.cpp\n> index 7afc8ca59..81b703a89 100644\n> --- a/src/libcamera/base/shared_fd.cpp\n> +++ b/src/libcamera/base/shared_fd.cpp\n> @@ -284,8 +284,11 @@ SharedFD::Descriptor::Descriptor(int fd, bool duplicate)\n>  \n>  SharedFD::Descriptor::~Descriptor()\n>  {\n> -       if (fd_ != -1)\n> -               close(fd_);\n> +       if (fd_ >= 0 && close(fd_) < 0) {\n> +               int ret = -errno;\n> +               LOG(SharedFD, Error) << \"Failed to close file descriptor \"\n> +                                    << fd_ << \": \" << strerror(-ret);\n> +       }\n>  }\n>  \n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/base/unique_fd.cpp b/src/libcamera/base/unique_fd.cpp\n> index d0649e4de..178c08c4b 100644\n> --- a/src/libcamera/base/unique_fd.cpp\n> +++ b/src/libcamera/base/unique_fd.cpp\n> @@ -7,6 +7,7 @@\n>  \n>  #include <libcamera/base/unique_fd.h>\n>  \n> +#include <string.h>\n>  #include <unistd.h>\n>  #include <utility>\n>  \n> @@ -98,8 +99,11 @@ void UniqueFD::reset(int fd)\n>  \n>         std::swap(fd, fd_);\n>  \n> -       if (fd >= 0)\n> -               close(fd);\n> +       if (fd >= 0 && close(fd) < 0) {\n> +               int ret = -errno;\n> +               LOG(UniqueFD, Error) << \"Failed to close file descriptor \"\n> +                                    << fd << \": \" << strerror(-ret);\n> +       }\n>  }\n>  \n>  /**\n> -- \n> 2.51.1.dirty\n>","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 B42DBC3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Oct 2025 15:05:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C71CD607FC;\n\tThu, 23 Oct 2025 17:05:48 +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 AB30F607ED\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 17:05:47 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6E0041127;\n\tThu, 23 Oct 2025 17:04:02 +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=\"Rocau0d/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761231842;\n\tbh=vfiCz+x494hniJzpSUYiDS8FKlO7u34REEP7ICTk2ao=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=Rocau0d/entblKw9D9Nl7VEWa5IGQyKOIpXZnTBdHdYskvCD5yxDibBwByI9gBX4p\n\tEtMg9FGNr/XFseejbJzz6Oje9hjG+A7VSaAeEc6ztVhlEwlJEJ25SM0DqT5rHnAEU8\n\t4jG2nOSK/pv1HGLWcX5ML2EsDs/jPaM0wh0Xmrx4=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251023145906.1088030-1-barnabas.pocze@ideasonboard.com>","References":"<20251023145906.1088030-1-barnabas.pocze@ideasonboard.com>","Subject":"Re: [PATCH v1] libcamera: base: {Unique,\n\tShared}FD: Warn if closing fails","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 23 Oct 2025 16:05:44 +0100","Message-ID":"<176123194494.2256500.12551924303498622982@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}},{"id":36406,"web_url":"https://patchwork.libcamera.org/comment/36406/","msgid":"<5a205348-62ae-45c1-8b02-5b8754e30c11@ideasonboard.com>","date":"2025-10-23T15:14:09","subject":"Re: [PATCH v1] libcamera: base: {Unique, Shared}FD: Warn if closing\n\tfails","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2025. 10. 23. 17:05 keltezéssel, Kieran Bingham írta:\n> Quoting Barnabás Pőcze (2025-10-23 15:59:06)\n>> If the contained file descriptor cannot be successfully closed,\n>> that is usually a sign of a more serious invariant violation,\n>> which deserves attention, so report those cases.\n> \n> Ohh has this happened for you?\n\nThere was an incorrect usage in pipewire that would've triggered this.\n\nhttps://gitlab.freedesktop.org/pipewire/pipewire/-/commit/429c0e03a3cb49631638627e4097119fd26905f8\n\n\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n>> ---\n>>   src/libcamera/base/shared_fd.cpp | 7 +++++--\n>>   src/libcamera/base/unique_fd.cpp | 8 ++++++--\n>>   2 files changed, 11 insertions(+), 4 deletions(-)\n>>\n>> diff --git a/src/libcamera/base/shared_fd.cpp b/src/libcamera/base/shared_fd.cpp\n>> index 7afc8ca59..81b703a89 100644\n>> --- a/src/libcamera/base/shared_fd.cpp\n>> +++ b/src/libcamera/base/shared_fd.cpp\n>> @@ -284,8 +284,11 @@ SharedFD::Descriptor::Descriptor(int fd, bool duplicate)\n>>   \n>>   SharedFD::Descriptor::~Descriptor()\n>>   {\n>> -       if (fd_ != -1)\n>> -               close(fd_);\n>> +       if (fd_ >= 0 && close(fd_) < 0) {\n>> +               int ret = -errno;\n>> +               LOG(SharedFD, Error) << \"Failed to close file descriptor \"\n>> +                                    << fd_ << \": \" << strerror(-ret);\n>> +       }\n>>   }\n>>   \n>>   } /* namespace libcamera */\n>> diff --git a/src/libcamera/base/unique_fd.cpp b/src/libcamera/base/unique_fd.cpp\n>> index d0649e4de..178c08c4b 100644\n>> --- a/src/libcamera/base/unique_fd.cpp\n>> +++ b/src/libcamera/base/unique_fd.cpp\n>> @@ -7,6 +7,7 @@\n>>   \n>>   #include <libcamera/base/unique_fd.h>\n>>   \n>> +#include <string.h>\n>>   #include <unistd.h>\n>>   #include <utility>\n>>   \n>> @@ -98,8 +99,11 @@ void UniqueFD::reset(int fd)\n>>   \n>>          std::swap(fd, fd_);\n>>   \n>> -       if (fd >= 0)\n>> -               close(fd);\n>> +       if (fd >= 0 && close(fd) < 0) {\n>> +               int ret = -errno;\n>> +               LOG(UniqueFD, Error) << \"Failed to close file descriptor \"\n>> +                                    << fd << \": \" << strerror(-ret);\n>> +       }\n>>   }\n>>   \n>>   /**\n>> -- \n>> 2.51.1.dirty\n>>","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 EC488BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Oct 2025 15:14:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 23C8A60800;\n\tThu, 23 Oct 2025 17:14:14 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0E348607EE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 17:14:13 +0200 (CEST)","from [192.168.33.33] (185.221.141.231.nat.pool.zt.hu\n\t[185.221.141.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DA4F7591;\n\tThu, 23 Oct 2025 17:12:27 +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=\"pzV46Tg0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761232348;\n\tbh=LzFm8dTquUasCBF3gwROP7+RPmqBajEGm3xwYeErwaQ=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=pzV46Tg05VpsO2O3s62Ml6FPdg5S8onQWD9LkfnSQ+YGc18A0+VV4T9q9ywlxtq17\n\tGOyBBWP1ywd5t71+ytTHqqv0KlJ0/t+roLkGvHakSl+l8lET3pVq0uHz6d7IRv4O0N\n\tYjuCftyvtZLMY3K3AuOvtJ4/ipF6CgyXJJvY3Sn4=","Message-ID":"<5a205348-62ae-45c1-8b02-5b8754e30c11@ideasonboard.com>","Date":"Thu, 23 Oct 2025 17:14:09 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v1] libcamera: base: {Unique, Shared}FD: Warn if closing\n\tfails","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20251023145906.1088030-1-barnabas.pocze@ideasonboard.com>\n\t<176123194494.2256500.12551924303498622982@ping.linuxembedded.co.uk>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<176123194494.2256500.12551924303498622982@ping.linuxembedded.co.uk>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}},{"id":36418,"web_url":"https://patchwork.libcamera.org/comment/36418/","msgid":"<jlsutf2ndr2wmsxfavm4csjx74lxpo2lwati44zwnogssu74nr@b4wwhwbuuks5>","date":"2025-10-24T07:38:10","subject":"Re: [PATCH v1] libcamera: base: {Unique, Shared}FD: Warn if closing\n\tfails","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Thu, Oct 23, 2025 at 04:59:06PM +0200, Barnabás Pőcze wrote:\n> If the contained file descriptor cannot be successfully closed,\n> that is usually a sign of a more serious invariant violation,\n> which deserves attention, so report those cases.\n>\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n> ---\n>  src/libcamera/base/shared_fd.cpp | 7 +++++--\n>  src/libcamera/base/unique_fd.cpp | 8 ++++++--\n>  2 files changed, 11 insertions(+), 4 deletions(-)\n>\n> diff --git a/src/libcamera/base/shared_fd.cpp b/src/libcamera/base/shared_fd.cpp\n> index 7afc8ca59..81b703a89 100644\n> --- a/src/libcamera/base/shared_fd.cpp\n> +++ b/src/libcamera/base/shared_fd.cpp\n> @@ -284,8 +284,11 @@ SharedFD::Descriptor::Descriptor(int fd, bool duplicate)\n>\n>  SharedFD::Descriptor::~Descriptor()\n>  {\n> -\tif (fd_ != -1)\n> -\t\tclose(fd_);\n> +\tif (fd_ >= 0 && close(fd_) < 0) {\n> +\t\tint ret = -errno;\n> +\t\tLOG(SharedFD, Error) << \"Failed to close file descriptor \"\n> +\t\t\t\t     << fd_ << \": \" << strerror(-ret);\n> +\t}\n>  }\n>\n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/base/unique_fd.cpp b/src/libcamera/base/unique_fd.cpp\n> index d0649e4de..178c08c4b 100644\n> --- a/src/libcamera/base/unique_fd.cpp\n> +++ b/src/libcamera/base/unique_fd.cpp\n> @@ -7,6 +7,7 @@\n>\n>  #include <libcamera/base/unique_fd.h>\n>\n> +#include <string.h>\n>  #include <unistd.h>\n>  #include <utility>\n>\n> @@ -98,8 +99,11 @@ void UniqueFD::reset(int fd)\n>\n>  \tstd::swap(fd, fd_);\n>\n> -\tif (fd >= 0)\n> -\t\tclose(fd);\n> +\tif (fd >= 0 && close(fd) < 0) {\n> +\t\tint ret = -errno;\n> +\t\tLOG(UniqueFD, Error) << \"Failed to close file descriptor \"\n> +\t\t\t\t     << fd << \": \" << strerror(-ret);\n> +\t}\n>  }\n>\n>  /**\n> --\n> 2.51.1.dirty\n>","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 93264BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Oct 2025 07:38:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 85A8260835;\n\tFri, 24 Oct 2025 09:38:16 +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 64597606E1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Oct 2025 09:38:15 +0200 (CEST)","from ideasonboard.com (mob-5-90-63-16.net.vodafone.it [5.90.63.16])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ACBF9A8F;\n\tFri, 24 Oct 2025 09:36:29 +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=\"uIZg62ol\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761291390;\n\tbh=Raz/b/YjDWkewSx5tCb4VTHdHDvL/KCIsZKTra9xaFA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=uIZg62olzi4amxiqMzmO7zRyPW++2cWiauN5c/ywde+Eeg/iFl43QQDCZ0UrCfLnk\n\tlsXrG0La82VDeynM4Yuw1rc/3EoCd7hD8ILubZYWm85FNPNsJy4NAnI0BVZ/s8etdq\n\tpoAsYypX8G3Kegs2HNjipgl6/guxHdyXq5uY/50c=","Date":"Fri, 24 Oct 2025 09:38:10 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1] libcamera: base: {Unique, Shared}FD: Warn if closing\n\tfails","Message-ID":"<jlsutf2ndr2wmsxfavm4csjx74lxpo2lwati44zwnogssu74nr@b4wwhwbuuks5>","References":"<20251023145906.1088030-1-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20251023145906.1088030-1-barnabas.pocze@ideasonboard.com>","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>"}},{"id":36422,"web_url":"https://patchwork.libcamera.org/comment/36422/","msgid":"<176129552140.199266.9217950291506224524@ping.linuxembedded.co.uk>","date":"2025-10-24T08:45:21","subject":"Re: [PATCH v1] libcamera: base: {Unique,\n\tShared}FD: Warn if closing fails","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Barnabás Pőcze (2025-10-23 16:14:09)\n> 2025. 10. 23. 17:05 keltezéssel, Kieran Bingham írta:\n> > Quoting Barnabás Pőcze (2025-10-23 15:59:06)\n> >> If the contained file descriptor cannot be successfully closed,\n> >> that is usually a sign of a more serious invariant violation,\n> >> which deserves attention, so report those cases.\n> > \n> > Ohh has this happened for you?\n> \n> There was an incorrect usage in pipewire that would've triggered this.\n> \n> https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/429c0e03a3cb49631638627e4097119fd26905f8\n> \n\nI see. And we /want/ the applications to have the fd - and we can't stop\nthem closing it - so indeed, this looks like a good protection to add.\n\nThanks.\n\n\n> \n> > \n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > \n> >> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> >> ---\n> >>   src/libcamera/base/shared_fd.cpp | 7 +++++--\n> >>   src/libcamera/base/unique_fd.cpp | 8 ++++++--\n> >>   2 files changed, 11 insertions(+), 4 deletions(-)\n> >>\n> >> diff --git a/src/libcamera/base/shared_fd.cpp b/src/libcamera/base/shared_fd.cpp\n> >> index 7afc8ca59..81b703a89 100644\n> >> --- a/src/libcamera/base/shared_fd.cpp\n> >> +++ b/src/libcamera/base/shared_fd.cpp\n> >> @@ -284,8 +284,11 @@ SharedFD::Descriptor::Descriptor(int fd, bool duplicate)\n> >>   \n> >>   SharedFD::Descriptor::~Descriptor()\n> >>   {\n> >> -       if (fd_ != -1)\n> >> -               close(fd_);\n> >> +       if (fd_ >= 0 && close(fd_) < 0) {\n> >> +               int ret = -errno;\n> >> +               LOG(SharedFD, Error) << \"Failed to close file descriptor \"\n> >> +                                    << fd_ << \": \" << strerror(-ret);\n> >> +       }\n> >>   }\n> >>   \n> >>   } /* namespace libcamera */\n> >> diff --git a/src/libcamera/base/unique_fd.cpp b/src/libcamera/base/unique_fd.cpp\n> >> index d0649e4de..178c08c4b 100644\n> >> --- a/src/libcamera/base/unique_fd.cpp\n> >> +++ b/src/libcamera/base/unique_fd.cpp\n> >> @@ -7,6 +7,7 @@\n> >>   \n> >>   #include <libcamera/base/unique_fd.h>\n> >>   \n> >> +#include <string.h>\n> >>   #include <unistd.h>\n> >>   #include <utility>\n> >>   \n> >> @@ -98,8 +99,11 @@ void UniqueFD::reset(int fd)\n> >>   \n> >>          std::swap(fd, fd_);\n> >>   \n> >> -       if (fd >= 0)\n> >> -               close(fd);\n> >> +       if (fd >= 0 && close(fd) < 0) {\n> >> +               int ret = -errno;\n> >> +               LOG(UniqueFD, Error) << \"Failed to close file descriptor \"\n> >> +                                    << fd << \": \" << strerror(-ret);\n> >> +       }\n> >>   }\n> >>   \n> >>   /**\n> >> -- \n> >> 2.51.1.dirty\n> >>\n>","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 890B0BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Oct 2025 08:45:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 18ACD60871;\n\tFri, 24 Oct 2025 10:45:27 +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 09A1C60817\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Oct 2025 10:45:25 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2B5FA177F;\n\tFri, 24 Oct 2025 10:43:39 +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=\"D7o8TnlE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761295419;\n\tbh=X/cgS/PACffADqF8/RQM+5hEOIMJjlk91Fc4IaCdbGI=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=D7o8TnlE4AUC6Y1YQ2KX88/5p0z7DNi2eE3HFoS8M9IZFu7swi9sCy1IlFWY9mCe6\n\tPKaEvyx+KHy7GYHqLrTYnEa39ODwNbNfFh0pZcHEwLrS5d3PaD9FEYrcPc7J+3CD0U\n\tpsh/6kbgWjwfTeDdt95c7C2ra0adFxr9tft6+qxA=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<5a205348-62ae-45c1-8b02-5b8754e30c11@ideasonboard.com>","References":"<20251023145906.1088030-1-barnabas.pocze@ideasonboard.com>\n\t<176123194494.2256500.12551924303498622982@ping.linuxembedded.co.uk>\n\t<5a205348-62ae-45c1-8b02-5b8754e30c11@ideasonboard.com>","Subject":"Re: [PATCH v1] libcamera: base: {Unique,\n\tShared}FD: Warn if closing fails","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 24 Oct 2025 09:45:21 +0100","Message-ID":"<176129552140.199266.9217950291506224524@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}}]