mirror of
https://github.com/springzfx/cgproxy.git
synced 2026-01-07 13:07:56 +08:00
optimize function get_cgroup2_mount_point
This commit is contained in:
10
cgattach.cpp
10
cgattach.cpp
@@ -32,10 +32,14 @@ bool validate(string pid, string cgroup) {
|
||||
}
|
||||
|
||||
string get_cgroup2_mount_point(){
|
||||
char cgroup2_mount_point[100];
|
||||
FILE* fp = popen("findmnt -t cgroup2 -n |cut -d' ' -f 1", "r");
|
||||
fscanf(fp,"%s",&cgroup2_mount_point);
|
||||
char cgroup2_mount_point[100]="";
|
||||
FILE* fp = popen("findmnt -t cgroup2 -n -o TARGET", "r");
|
||||
int count=fscanf(fp,"%s",&cgroup2_mount_point);
|
||||
fclose(fp);
|
||||
if (count=0){
|
||||
fprintf(stderr, "cgroup2 not supported\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return cgroup2_mount_point;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user