aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-01-15 21:46:45 -0600
committerRob Landley <rob@landley.net>2018-01-15 21:46:45 -0600
commit416397e14858c75a9bf20d05f7729595e03943df (patch)
tree5abfd43ade524361f99a89e3d9816daa18a0a1bf /toys
parenta75364e25676c653c17e30592aa31548ea2a8fc0 (diff)
downloadtoybox-416397e14858c75a9bf20d05f7729595e03943df.tar.gz
Fix "ps -T 1234" to show thread belonging to that PID.
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/ps.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index fd9b54bc..7741dcd3 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -680,8 +680,11 @@ static int get_ps(struct dirtree *new)
memset(slot, 0, sizeof(tb->slot));
tb->slot[SLOT_tid] = *slot = atol(new->name);
- if (TT.threadparent && TT.threadparent->extra)
- if (*slot == *(((struct carveup *)TT.threadparent->extra)->slot)) return 0;
+ if (TT.threadparent && TT.threadparent->extra) {
+ *slot = *(((struct carveup *)TT.threadparent->extra)->slot);
+ // Parent also shows up as a thread, discard duplicate
+ if (*slot == tb->slot[SLOT_tid]) return 0;
+ }
fd = dirtree_parentfd(new);
len = 2048;