Commit 67a65fe3 authored by Pavel Emelyanov's avatar Pavel Emelyanov

cg: Strip trailing \n from property's value

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent cf8b7c8f
......@@ -280,6 +280,20 @@ static int find_dir(const char *path, struct list_head *dirs, struct cgroup_dir
return NO_MATCH;
}
/*
* Strips trailing '\n' from the string
*/
static inline char *strip(char *str)
{
char *e;
e = strchr(str, '\0');
if (e != str && *(e - 1) == '\n')
*(e - 1) = '\0';
return str;
}
/*
* Currently this function only supports properties that have 1 value, under 100
* chars
......@@ -315,7 +329,7 @@ static int read_cgroup_prop(struct cgroup_prop *property, const char *fpath)
return -1;
}
property->value = xstrdup(buf);
property->value = xstrdup(strip(buf));
if (!property->value)
return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment