Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
fac59a22b0 | |||
e598e6a20b | |||
6568720c6d |
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "extern/Unity"]
|
||||||
|
path = extern/Unity
|
||||||
|
url = https://github.com/ThrowTheSwitch/Unity.git
|
3
examples/cp/.gitignore
vendored
Normal file
3
examples/cp/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
c
|
||||||
|
c_cgroup
|
||||||
|
ml
|
@ -31,7 +31,37 @@ off_t get_file_size(int fd) {
|
|||||||
/*
|
/*
|
||||||
* Move self to a leaf node of the cgroup.
|
* Move self to a leaf node of the cgroup.
|
||||||
*/
|
*/
|
||||||
int leaf_self() {}
|
int leaf_self() {
|
||||||
|
int cgroup_fd = open("/proc/self/cgroup", O_RDONLY);
|
||||||
|
if (cgroup_fd == -1) {
|
||||||
|
perror("open");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lseek(cgroup_fd, 3, SEEK_SET) == -1) {
|
||||||
|
perror("lseek");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char cgroup_root_dir[1024] = "/sys/fs/cgroup";
|
||||||
|
|
||||||
|
off_t len;
|
||||||
|
if ((len = read(cgroup_fd, cgroup_root_dir + 14, 1010)) == -1) {
|
||||||
|
perror("read");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
cgroup_root_dir[len + 17] = 0x00;
|
||||||
|
|
||||||
|
fprintf(stderr, "%s\n", cgroup_root_dir);
|
||||||
|
|
||||||
|
int cgroup_dd = open(cgroup_root_dir, O_DIRECTORY);
|
||||||
|
if (cgroup_dd == -1) {
|
||||||
|
perror("open");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Perform the copy between the two file descriptors.
|
* Perform the copy between the two file descriptors.
|
||||||
@ -112,6 +142,8 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// setup a cgroup for the child
|
// setup a cgroup for the child
|
||||||
|
if (leaf_self() == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
// wait for the child to pause and restart it
|
// wait for the child to pause and restart it
|
||||||
int status;
|
int status;
|
||||||
|
0
examples/cp/cp_effects.ml
Normal file
0
examples/cp/cp_effects.ml
Normal file
0
examples/echo/echo.c
Normal file
0
examples/echo/echo.c
Normal file
0
examples/echo/echo.ml
Normal file
0
examples/echo/echo.ml
Normal file
0
examples/echo/echo_effects.ml
Normal file
0
examples/echo/echo_effects.ml
Normal file
0
examples/echo/echo_priv.c
Normal file
0
examples/echo/echo_priv.c
Normal file
1
extern/Unity
vendored
Submodule
1
extern/Unity
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 8ba01386008196a92ef4fdbdb0b00f2434c79563
|
Reference in New Issue
Block a user