procps-3.2.8-ps-cgroup-suppress-root-group.patch 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. --- procps-3.2.8/ps/output.c 2010-05-18 06:00:18.000000000 +0200
  2. +++ procps-3.2.8.lennart/ps/output.c 2010-05-18 05:59:46.000000000 +0200
  3. @@ -1109,7 +1109,7 @@
  4. static int pr_cgroup(char *restrict const outbuf, const proc_t *restrict const pp){
  5. char filename[48];
  6. FILE *fd;
  7. - int counter = 0;
  8. + int counter = 0, last_begin = 0, slash = 0;
  9. int c;
  10. int is_cgroup = 0;
  11. @@ -1121,15 +1121,22 @@
  12. if (is_cgroup == 0) {
  13. if (c == ':') {
  14. is_cgroup = 1;
  15. + slash = 0;
  16. if (counter>0)
  17. outbuf[counter++]=';';
  18. }
  19. }else
  20. - if ((c == '\n') || (c == '\0'))
  21. - is_cgroup = 0;
  22. + if ((c == '\n') || (c == '\0')){
  23. + if (slash) /* if the last char was a / this process is in the root cgroup which we should suppress */
  24. + counter = last_begin;
  25. else
  26. + last_begin = counter;
  27. + is_cgroup = 0;
  28. + } else {
  29. + slash = c == '/';
  30. outbuf[counter++]=c;
  31. }
  32. + }
  33. outbuf[counter]='\0';
  34. close(fd);
  35. if (counter>0)