|
|
6ec062 |
diff --git a/ps/output.c b/ps/output.c
|
|
|
6ec062 |
index 501e29a..5f011b1 100644
|
|
|
6ec062 |
--- a/ps/output.c
|
|
|
6ec062 |
+++ b/ps/output.c
|
|
|
6ec062 |
@@ -1343,6 +1343,41 @@
|
|
|
6ec062 |
return snprintf(outbuf, COLWID, "%s", vals[lines_to_next_header%4u]);
|
|
|
6ec062 |
}
|
|
|
6ec062 |
|
|
|
6ec062 |
+static int pr_thcgr(char *restrict const outbuf, const proc_t *restrict const pp){
|
|
|
6ec062 |
+ char filename[48];
|
|
|
6ec062 |
+ FILE *fd;
|
|
|
6ec062 |
+ int counter = 0;
|
|
|
6ec062 |
+ int c;
|
|
|
6ec062 |
+ int is_cgroup = 0;
|
|
|
6ec062 |
+
|
|
|
6ec062 |
+ outbuf[0]='\0';
|
|
|
6ec062 |
+ snprintf(filename, sizeof filename, "/proc/%d/task/%d/cgroup", pp->tgid, pp->tid);
|
|
|
6ec062 |
+ fd = fopen(filename, "r");
|
|
|
6ec062 |
+ if (likely(fd == NULL)) goto fail;
|
|
|
6ec062 |
+ while (( (c = fgetc(fd)) != EOF) && (counter<665)) {
|
|
|
6ec062 |
+ if (is_cgroup == 0) {
|
|
|
6ec062 |
+ if (c == ':') {
|
|
|
6ec062 |
+ is_cgroup = 1;
|
|
|
6ec062 |
+ if (counter>0)
|
|
|
6ec062 |
+ outbuf[counter++]=';';
|
|
|
6ec062 |
+ }
|
|
|
6ec062 |
+ }else
|
|
|
6ec062 |
+ if ((c == '\n') || (c == '\0'))
|
|
|
6ec062 |
+ is_cgroup = 0;
|
|
|
6ec062 |
+ else
|
|
|
6ec062 |
+ outbuf[counter++]=c;
|
|
|
6ec062 |
+ }
|
|
|
6ec062 |
+ outbuf[counter]='\0';
|
|
|
6ec062 |
+ fclose(fd);
|
|
|
6ec062 |
+ if (counter>0)
|
|
|
6ec062 |
+ return counter;
|
|
|
6ec062 |
+fail:
|
|
|
6ec062 |
+ outbuf[0] = '-';
|
|
|
6ec062 |
+ outbuf[1] = '\0';
|
|
|
6ec062 |
+ return 1;
|
|
|
6ec062 |
+}
|
|
|
6ec062 |
+
|
|
|
6ec062 |
+
|
|
|
6ec062 |
/***************************************************************************/
|
|
|
6ec062 |
/*************************** other stuff ***********************************/
|
|
|
6ec062 |
|
|
|
6ec062 |
@@ -1623,6 +1658,7 @@
|
|
|
6ec062 |
{"taskid", "TASKID", pr_nop, sr_nop, 5, 0, SUN, TO|PIDMAX|RIGHT}, // is this a thread ID?
|
|
|
6ec062 |
{"tdev", "TDEV", pr_nop, sr_nop, 4, 0, XXX, AN|RIGHT},
|
|
|
6ec062 |
{"tgid", "TGID", pr_procs, sr_procs, 5, 0, LNX, PO|PIDMAX|RIGHT},
|
|
|
6ec062 |
+{"thcgr", "THCGR", pr_thcgr, sr_nop, 35, 0, LNX, PO|LEFT}, /* thread cgroups */
|
|
|
6ec062 |
{"thcount", "THCNT", pr_nlwp, sr_nlwp, 5, 0, AIX, PO|RIGHT},
|
|
|
6ec062 |
{"tid", "TID", pr_tasks, sr_tasks, 5, 0, AIX, TO|PIDMAX|RIGHT},
|
|
|
6ec062 |
{"time", "TIME", pr_time, sr_time, 8, 0, U98, ET|RIGHT}, /*cputime*/ /* was 6 wide */
|
|
|
6ec062 |
diff --git a/ps/ps.1 b/ps/ps.1
|
|
|
6ec062 |
index b90adc8..b8d6c81 100644
|
|
|
6ec062 |
--- a/ps/ps.1
|
|
|
6ec062 |
+++ b/ps/ps.1
|
|
|
6ec062 |
@@ -1713,6 +1713,10 @@
|
|
|
6ec062 |
It is the process ID of the thread group leader.
|
|
|
6ec062 |
T}
|
|
|
6ec062 |
|
|
|
6ec062 |
+thcgr THCGR T{
|
|
|
6ec062 |
+display control groups to which the thread belongs.
|
|
|
6ec062 |
+T}
|
|
|
6ec062 |
+
|
|
|
6ec062 |
thcount THCNT T{
|
|
|
6ec062 |
see
|
|
|
6ec062 |
.BR nlwp .
|