Fix cgroup cpu controller file leak (#31398)
This commit is contained in:
@ -22,6 +22,8 @@
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#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<false>("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) {
|
||||
|
||||
Reference in New Issue
Block a user