Changelog since v1:
o Use fopen/fprintf/fclose instead of open/write/close.
o Add the error handling against fclose.
cg_set_control_value() is the function for setting a value to a file
of cgroup file system. And current function does not handle the error
of writing to a file. So we cannot know whether setting value is
enable or not. This patch add the error handling for knowing it.
Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
return ECGROUPVALUENOTEXIST;
}
- fprintf(control_file, "%s", val);
- fclose(control_file);
+ if (fprintf(control_file, "%s", val) < 0) {
+ last_errno = errno;
+ fclose(control_file);
+ return ECGOTHER;
+ }
+ if (fclose(control_file) < 0) {
+ last_errno = errno;
+ return ECGOTHER;
+ }
return 0;
}