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