From c3a1239efee4d720080f216547be4cd22253f861 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sun, 11 Dec 2011 12:00:50 -0600 Subject: [PATCH] library: once again properly ignore a final empty cgroup Commit a5881b5a4e5056d13906ce6128f6aa180d67d60e, addressing command lines with a trailing space, produced an undesirable side effect in the fill_cgroup_cvt() function. This patch restores correct cgroup behavior while still producing command lines with no trailing space. --- proc/readproc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proc/readproc.c b/proc/readproc.c index 57870ef3..bbfd6292 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -611,9 +611,10 @@ static int read_unvectored(char *restrict const dst, unsigned sz, const char* wh } close(fd); if(n){ - int i=n-1; + int i=n; while(i--) if(dst[i]=='\n' || dst[i]=='\0') dst[i]=sep; + if(dst[n-1]==' ') dst[n-1]='\0'; } dst[n] = '\0'; return n;