28 return unexpected(std::make_error_code(std::errc::invalid_argument));
30 char const*
const candidates[] = {
"cgroup.threads",
"tasks" };
31 std::string
const value = std::to_string(tid) +
"\n";
32 for (
auto const* file : candidates)
34 std::string
const path = cgroup_dir +
"/" + file;
35 int const descriptor = open(path.c_str(), O_WRONLY | O_CLOEXEC);
39 std::size_t offset = 0;
40 while (offset < value.size())
42 auto const written = write(descriptor, value.data() + offset, value.size() - offset);
45 offset +=
static_cast<std::size_t
>(written);
48 if (written < 0 && errno == EINTR)
52 (void)close(descriptor);
53 if (offset == value.size())
56 return unexpected(std::make_error_code(std::errc::operation_not_permitted));