Skip to content

Commit

Permalink
f: fix compiler error w/ pclose
Browse files Browse the repository at this point in the history
  • Loading branch information
ksedgwic committed Aug 8, 2024
1 parent 129e108 commit f850706
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Util/BacktraceException.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
class BacktraceException : public T {
public:
Expand Down Expand Up @@ -76,7 +84,7 @@ class BacktraceException : public T {

std::array<char, 128> buffer;
std::string result;
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
std::unique_ptr<FILE, PcloseDeleter> pipe(popen(cmd, "r"));

if (!pipe) {
return " -- error: unable to open addr2line";
Expand Down

0 comments on commit f850706

Please sign in to comment.