From 2b66afffb8b51a4e68b508be1858dcde7706142e Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 27 Sep 2016 12:20:41 -0700 Subject: Show thread names with "ps -T" on Android. Android uses NAME rather than CMD by default, but that's not what we want with -T. Noticed because it broke systrace's reporting of thread names (see https://developer.android.com/studio/profile/systrace.html). Bug: 31741954 --- toys/posix/ps.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/toys/posix/ps.c b/toys/posix/ps.c index 6a128bde..bb6bcbad 100644 --- a/toys/posix/ps.c +++ b/toys/posix/ps.c @@ -1178,7 +1178,9 @@ void ps_main(void) else if (toys.optflags&FLAG_l) not_o = "F,S,UID,%sPPID,C,PRI,NI,ADDR,SZ,WCHAN,TTY,TIME,CMD"; else if (CFG_TOYBOX_ON_ANDROID) - not_o = "USER,%sPPID,VSIZE,RSS,WCHAN:10,ADDR:10=PC,S,NAME"; + sprintf(not_o = toybuf+128, + "USER,%%sPPID,VSIZE,RSS,WCHAN:10,ADDR:10=PC,S,%s", + (toys.optflags&FLAG_T) ? "CMD" : "NAME"); sprintf(toybuf, not_o, (toys.optflags & FLAG_T) ? "PID,TID," : "PID,"); // Init TT.fields. This only uses toybuf if TT.ps.o is NULL -- cgit v1.2.3