If read() returns with errno == EIDRM, we know the cgroup has been
removed.

Signed-off-by: Li Zefan <lize...@huawei.com>
---
 tools/cgroup/cgroup_event_listener.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/tools/cgroup/cgroup_event_listener.c 
b/tools/cgroup/cgroup_event_listener.c
index 4eb5507..19e3d4a 100644
--- a/tools/cgroup/cgroup_event_listener.c
+++ b/tools/cgroup/cgroup_event_listener.c
@@ -62,18 +62,16 @@ int main(int argc, char **argv)
                if (ret == -1) {
                        if (errno == EINTR)
                                continue;
-                       err(1, "Cannot read from eventfd");
+                       if (errno != EIDRM)
+                               err(1, "Cannot read from eventfd");
                }
-               assert(ret == sizeof(result));
 
-               ret = access(event_control_path, W_OK);
-               if ((ret == -1) && (errno == ENOENT)) {
-                       puts("The cgroup seems to have removed.");
+               if (ret == -1 && errno == EIDRM) {
+                       puts("The cgroup has been removed.");
                        break;
                }
 
-               if (ret == -1)
-                       err(1, "cgroup.event_control is not accessible any 
more");
+               assert(ret == sizeof(result));
 
                printf("%s %s: crossed\n", argv[1], argv[2]);
        }
-- 
1.8.0.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to