xianlubird / mydocker

<<自己动手写docker>> 源码
Apache License 2.0
1.98k stars 560 forks source link

配套书籍2.2.3章节的例子cgroup随机不生效 #86

Open liuguangwei opened 2 years ago

liuguangwei commented 2 years ago

该例子中存在线程问题,如果执行 stress命令早于创建文件夹,会导致创建的任务pid不写入testmemorylimit/tasks中,而是写入user.slice/tasks中,内存限制失效,需要添加延迟操作,确保testmemorylimit先创建 image

123liuziming commented 1 year ago

+1

xjhonly commented 1 year ago

我运行这个加了延迟的代码。会有这个报错 current pid 1 stress: info: [5] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd stress: FAIL: [5] (415) <-- worker 6 got signal 9 stress: WARN: [5] (417) now reaping child worker processes stress: FAIL: [5] (421) kill error: No such process stress: FAIL: [5] (451) failed run completed in 0s exit status 1