From f8507067daa136ab8c97d6ac444ca56130b33a0b Mon Sep 17 00:00:00 2001 From: Ken Sedgwick Date: Thu, 8 Aug 2024 11:15:18 -0700 Subject: [PATCH] f: fix compiler error w/ pclose --- Util/BacktraceException.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Util/BacktraceException.hpp b/Util/BacktraceException.hpp index a0ed2d017..313efb834 100644 --- a/Util/BacktraceException.hpp +++ b/Util/BacktraceException.hpp @@ -18,6 +18,14 @@ namespace Util { * deferred until `what()` is called on the handled exception. */ +struct PcloseDeleter { + void operator()(FILE* fp) const { + if (fp) { + pclose(fp); + } + } +}; + template class BacktraceException : public T { public: @@ -76,7 +84,7 @@ class BacktraceException : public T { std::array buffer; std::string result; - std::unique_ptr pipe(popen(cmd, "r"), pclose); + std::unique_ptr pipe(popen(cmd, "r")); if (!pipe) { return " -- error: unable to open addr2line";