source: patches/procps-3.2.8-ps_cgroup-1.patch@ c27f76e

clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since c27f76e was de18e330, checked in by Joe Ciccone <jciccone@…>, 14 years ago

Patch procps so that ps supports process control groups.

  • Property mode set to 100644
File size: 3.0 KB
  • ps/output.c

    Submitted By: Joe Ciccone <jciccone@gmail.com>
    Date: 2011-01-30
    Initial Package Version: 3.2.7
    Origin: Fedora Git
            http://pkgs.fedoraproject.org/gitweb/?p=procps.git;a=blob_plain;f=procps-3.2.7-ps-cgroup.patch;h=b638c4f9a826040099f10e9282aad0d31ec5f03f;hb=HEAD
            http://pkgs.fedoraproject.org/gitweb/?p=procps.git;a=blob_plain;f=procps-3.2.8-ps-cgroup-suppress-root-group.patch;h=4b192c1fb4aa7684b7e57606713ca68690d77845;hb=HEAD
    Upstream Status: Unknown
    Description: Adds the ability for ps to output process(es) cgroups.
    
    diff -Naur procps-3.2.8.orig/ps/output.c procps-3.2.8/ps/output.c
    old new  
    10991099  return snprintf(outbuf, COLWID, "*");
    11001100}
    11011101
     1102static int pr_cgroup(char *restrict const outbuf, const proc_t *restrict const pp){
     1103  char filename[48];
     1104  FILE *fd;
     1105  int counter = 0, last_begin = 0, slash = 0;
     1106  int c;
     1107  int is_cgroup = 0;
     1108
     1109  outbuf[0]='\0';
     1110  snprintf(filename, sizeof filename, "/proc/%d/cgroup", pp->tgid);
     1111  fd = fopen(filename, "r");
     1112  if (likely(fd == NULL)) goto fail;
     1113  while (( (c = fgetc(fd)) != EOF) && (counter<665)) {
     1114    if (is_cgroup == 0) {
     1115      if (c == ':') {
     1116        is_cgroup = 1;
     1117        slash = 0;
     1118        if (counter>0)
     1119          outbuf[counter++]=';';
     1120      }
     1121    }else
     1122      if ((c == '\n') || (c == '\0')){
     1123        if (slash)  /* if the last char was a / this process is in the root cgroup which we should suppress */
     1124            counter = last_begin;
     1125      else
     1126            last_begin = counter;
     1127        is_cgroup = 0;
     1128      } else {
     1129        slash = c == '/';
     1130        outbuf[counter++]=c;
     1131  }
     1132  }
     1133  outbuf[counter]='\0';
     1134  close(fd);
     1135  if (counter>0)
     1136    return counter;
     1137fail:
     1138  outbuf[0] = '-';
     1139  outbuf[1] = '\0';
     1140  return 1;
     1141}
    11021142
    11031143/****************** FLASK & seLinux security stuff **********************/
    11041144// move the bulk of this to libproc sometime
     
    12931333{"bsdtime",   "TIME",    pr_bsdtime,  sr_nop,     6,   0,    LNX, ET|RIGHT},
    12941334{"c",         "C",       pr_c,        sr_pcpu,    2,   0,    SUN, ET|RIGHT},
    12951335{"caught",    "CAUGHT",  pr_sigcatch, sr_nop,     9,   0,    BSD, TO|SIGNAL}, /*sigcatch*/
     1336{"cgroup",    "CGROUP",  pr_cgroup,   sr_nop,    35,   0,    LNX, PO|LEFT},  /* cgroups*/
    12961337{"class",     "CLS",     pr_class,    sr_sched,   3,   0,    XXX, TO|LEFT},
    12971338{"cls",       "CLS",     pr_class,    sr_sched,   3,   0,    HPU, TO|RIGHT}, /*says HPUX or RT*/
    12981339{"cmaj_flt",  "-",       pr_nop,      sr_cmaj_flt, 1,  0,    LNX, AN|RIGHT},
  • procps-3.2.8

    diff -Naur procps-3.2.8.orig/ps/ps.1 procps-3.2.8/ps/ps.1
    old new  
    904904displayed.  (alias\ \fBsig_catch\fR,\ \fBsigcatch\fR).
    905905T}
    906906
     907cgroup  CGROUP  T{
     908display control groups to which the process belonges.
     909T}
     910
    907911class   CLS     T{
    908912scheduling class of the process.  (alias\ \fBpolicy\fR,\ \fBcls\fR).
    909913Field's possible values are:
Note: See TracBrowser for help on using the repository browser.