diff --git a/be/src/agent/cgroup_cpu_ctl.cpp b/be/src/agent/cgroup_cpu_ctl.cpp index ff44e5630e..c94a3c05f1 100644 --- a/be/src/agent/cgroup_cpu_ctl.cpp +++ b/be/src/agent/cgroup_cpu_ctl.cpp @@ -22,6 +22,8 @@ #include +#include "util/defer_op.h" + namespace doris { Status CgroupCpuCtl::init() { @@ -84,6 +86,12 @@ Status CgroupCpuCtl::write_cg_sys_file(std::string file_path, int value, std::st return Status::InternalError("open path failed, path={}", file_path); } + Defer defer {[&]() { + if (-1 == ::close(fd)) { + LOG(INFO) << "close file fd failed"; + } + }}; + auto str = fmt::format("{}\n", value); int ret = write(fd, str.c_str(), str.size()); if (ret == -1) {