@@ -120,7 +120,8 @@ photoproc(struct tstat *tasklist, int maxtask)
120
120
121
121
while (fgets (line , sizeof line , fp ))
122
122
{
123
- if (memcmp (line , "0::" , 3 ) == 0 ) { // equal?
123
+ if (memcmp (line , "0::" , 3 ) == 0 ) // equal?
124
+ {
124
125
supportflags |= CGROUPV2 ;
125
126
break ;
126
127
}
@@ -1056,37 +1057,39 @@ proccgroupv2(struct tstat *curtask)
1056
1057
int hash , pathlen , restlen , nslash ;
1057
1058
struct cgroupv2vals * pvals = NULL , * ptarget ;
1058
1059
char * p , * slashes [MAXSLASH ];
1059
- int ret ;
1060
1060
1061
1061
/*
1062
1062
** open the cgroup file of the current process and
1063
- ** read one line that should start with '0::' for cgroup v2
1063
+ ** read the line that starts with '0::' for cgroup v2
1064
1064
*/
1065
+ curtask -> gen .cgpath [0 ] = '\0' ;
1066
+
1065
1067
if ( (fp = fopen ("cgroup" , "r" )) )
1066
1068
{
1067
1069
while (fgets (line , sizeof line , fp ))
1068
1070
{
1069
1071
if ( memcmp (line , "0::" , 3 ) == 0 ) // equal?
1070
1072
{
1071
- ret = 1 ;
1072
1073
line [ strlen (line )- 1 ] = '\0' ; // remove newline
1073
1074
1074
1075
relpath = line + 3 ;
1075
1076
1076
1077
strncpy (curtask -> gen .cgpath , relpath ,
1077
1078
sizeof curtask -> gen .cgpath );
1079
+
1078
1080
curtask -> gen .cgpath [sizeof curtask -> gen .cgpath - 1 ] = '\0' ;
1081
+
1082
+ break ;
1079
1083
}
1080
1084
}
1081
1085
1082
- if (ret != 1 )
1083
- curtask -> gen .cgpath [0 ] = '\0' ;
1084
-
1085
1086
fclose (fp );
1087
+
1088
+ if (curtask -> gen .cgpath [0 ] == '\0' )
1089
+ return 0 ; // no cgroupv2 support
1086
1090
}
1087
1091
else // open failed; no permission
1088
1092
{
1089
- curtask -> gen .cgpath [0 ] = '\0' ;
1090
1093
return 2 ;
1091
1094
}
1092
1095
0 commit comments