MCPcopy Create free account
hub / github.com/apache/mesos / tasks

Function tasks

src/linux/cgroups.cpp:890–924  ·  view source on GitHub ↗

Return a set of tasks (schedulable entities) for the cgroup. If control == "cgroup.procs" these are processes else if control == "tasks" they are all tasks, roughly equivalent to threads.

Source from the content-addressed store, hash-verified

888// If control == "cgroup.procs" these are processes else
889// if control == "tasks" they are all tasks, roughly equivalent to threads.
890Try<set<pid_t>> tasks(
891 const string& hierarchy,
892 const string& cgroup,
893 const string& control)
894{
895 // Note: (from cgroups/cgroups.txt documentation)
896 // cgroup.procs: list of thread group IDs in the cgroup. This list is not
897 // guaranteed to be sorted or free of duplicate TGIDs, and userspace should
898 // sort/uniquify the list if this property is required.
899 Try<string> value = cgroups::read(hierarchy, cgroup, control);
900 if (value.isError()) {
901 return Error("Failed to read cgroups control '" +
902 control + "': " + value.error());
903 }
904
905 // Parse the values read from the control file and insert into a set. This
906 // ensures they are unique (and also sorted).
907 set<pid_t> pids;
908 istringstream ss(value.get());
909 ss >> dec;
910 while (!ss.eof()) {
911 pid_t pid;
912 ss >> pid;
913
914 if (ss.fail()) {
915 if (!ss.eof()) {
916 return Error("Failed to parse '" + value.get() + "'");
917 }
918 } else {
919 pids.insert(pid);
920 }
921 }
922
923 return pids;
924}
925
926} // namespace internal {
927

Callers 2

processesFunction · 0.85
threadsFunction · 0.85

Calls 7

insertMethod · 0.80
readFunction · 0.70
errorMethod · 0.65
ErrorFunction · 0.50
isErrorMethod · 0.45
getMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected