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

clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since b37f00b 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
RevLine 
[de18e330]1Submitted By: Joe Ciccone <jciccone@gmail.com>
2Date: 2011-01-30
3Initial Package Version: 3.2.7
4Origin: Fedora Git
5 http://pkgs.fedoraproject.org/gitweb/?p=procps.git;a=blob_plain;f=procps-3.2.7-ps-cgroup.patch;h=b638c4f9a826040099f10e9282aad0d31ec5f03f;hb=HEAD
6 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
7Upstream Status: Unknown
8Description: Adds the ability for ps to output process(es) cgroups.
9
10diff -Naur procps-3.2.8.orig/ps/output.c procps-3.2.8/ps/output.c
11--- procps-3.2.8.orig/ps/output.c 2009-05-10 15:24:50.000000000 -0400
12+++ procps-3.2.8/ps/output.c 2011-01-30 12:58:30.530497002 -0500
13@@ -1099,6 +1099,46 @@
14 return snprintf(outbuf, COLWID, "*");
15 }
16
17+static int pr_cgroup(char *restrict const outbuf, const proc_t *restrict const pp){
18+ char filename[48];
19+ FILE *fd;
20+ int counter = 0, last_begin = 0, slash = 0;
21+ int c;
22+ int is_cgroup = 0;
23+
24+ outbuf[0]='\0';
25+ snprintf(filename, sizeof filename, "/proc/%d/cgroup", pp->tgid);
26+ fd = fopen(filename, "r");
27+ if (likely(fd == NULL)) goto fail;
28+ while (( (c = fgetc(fd)) != EOF) && (counter<665)) {
29+ if (is_cgroup == 0) {
30+ if (c == ':') {
31+ is_cgroup = 1;
32+ slash = 0;
33+ if (counter>0)
34+ outbuf[counter++]=';';
35+ }
36+ }else
37+ if ((c == '\n') || (c == '\0')){
38+ if (slash) /* if the last char was a / this process is in the root cgroup which we should suppress */
39+ counter = last_begin;
40+ else
41+ last_begin = counter;
42+ is_cgroup = 0;
43+ } else {
44+ slash = c == '/';
45+ outbuf[counter++]=c;
46+ }
47+ }
48+ outbuf[counter]='\0';
49+ close(fd);
50+ if (counter>0)
51+ return counter;
52+fail:
53+ outbuf[0] = '-';
54+ outbuf[1] = '\0';
55+ return 1;
56+}
57
58 /****************** FLASK & seLinux security stuff **********************/
59 // move the bulk of this to libproc sometime
60@@ -1293,6 +1333,7 @@
61 {"bsdtime", "TIME", pr_bsdtime, sr_nop, 6, 0, LNX, ET|RIGHT},
62 {"c", "C", pr_c, sr_pcpu, 2, 0, SUN, ET|RIGHT},
63 {"caught", "CAUGHT", pr_sigcatch, sr_nop, 9, 0, BSD, TO|SIGNAL}, /*sigcatch*/
64+{"cgroup", "CGROUP", pr_cgroup, sr_nop, 35, 0, LNX, PO|LEFT}, /* cgroups*/
65 {"class", "CLS", pr_class, sr_sched, 3, 0, XXX, TO|LEFT},
66 {"cls", "CLS", pr_class, sr_sched, 3, 0, HPU, TO|RIGHT}, /*says HPUX or RT*/
67 {"cmaj_flt", "-", pr_nop, sr_cmaj_flt, 1, 0, LNX, AN|RIGHT},
68diff -Naur procps-3.2.8.orig/ps/ps.1 procps-3.2.8/ps/ps.1
69--- procps-3.2.8.orig/ps/ps.1 2009-05-10 15:38:17.000000000 -0400
70+++ procps-3.2.8/ps/ps.1 2011-01-30 12:58:08.382497001 -0500
71@@ -904,6 +904,10 @@
72 displayed. (alias\ \fBsig_catch\fR,\ \fBsigcatch\fR).
73 T}
74
75+cgroup CGROUP T{
76+display control groups to which the process belonges.
77+T}
78+
79 class CLS T{
80 scheduling class of the process. (alias\ \fBpolicy\fR,\ \fBcls\fR).
81 Field's possible values are:
Note: See TracBrowser for help on using the repository browser.