Cgred just migrate forked process when the parent's cgroup is changed, so that the forked process can stay in the same cgroup which match the cgred rules with it's parent. But there is a situation when parent process fork a child process, and exited before it moved into the cgroup matched the rules successfullly. The forked child process is also failed into the cgroup. This result is inconsistent with rules. So this patch fix the problem. Just apply rule for forked process when parent process exited when forking.
But I'm not sure whether the fix is suitable. Because the other way(just remove the cgre_was_parent_changed_when_forking() for forked processes) will affect cgclassify --sticky. But this way is not which I have done some test. Signed-off-by: Weng Meiling <wengmeiling.w...@huawei.com> --- src/daemon/cgrulesengd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/daemon/cgrulesengd.c b/src/daemon/cgrulesengd.c index 367b898..5e254c8 100644 --- a/src/daemon/cgrulesengd.c +++ b/src/daemon/cgrulesengd.c @@ -265,6 +265,8 @@ static int cgre_was_parent_changed_when_forking(const struct proc_event *ev) pid_t parent_pid; __u64 timestamp_child; __u64 timestamp_parent; + char path[FILENAME_MAX]; + struct stat buff_stat; parent_pid = ev->event_data.fork.parent_pid; timestamp_child = ev->timestamp_ns; @@ -279,6 +281,9 @@ static int cgre_was_parent_changed_when_forking(const struct proc_event *ev) continue; return 1; } + sprintf(path, "/proc/%d", parent_pid); + if (stat(path, &buff_stat) < 0) + return 1; return 0; } -- 1.8.2.2 ------------------------------------------------------------------------------ Put Bad Developers to Shame Dominate Development with Jenkins Continuous Integration Continuously Automate Build, Test & Deployment Start a new project now. Try Jenkins in the cloud. http://p.sf.net/sfu/13600_Cloudbees _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel