TO reproduce, run python program:
from functools import partial import os import subprocess from threading import Thread import time import prctl def thrd(num): prctl.set_name('thr_name_' + str(num)) time.sleep(10) def main(): for i in xrange(2): t = Thread(target=partial(thrd, i)) t.daemon = True t.start() prctl.set_name('proc_name') time.sleep(0.1) subprocess.call(['pstree', '-pa', str(os.getpid())]) subprocess.call(['top', '-Hbn1', '-p', str(os.getpid())]) if __name__ == '__main__': main()
proc_name,6641 /home/mmarkk/src/pytest/qwe.py |-pstree,6644 -pa 6641 |-{proc_name},6642 `-{proc_name},6643 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 6641 mmarkk 20 0 180m 6168 2892 S 0 0.2 0:00.02 proc_name 6642 mmarkk 20 0 180m 6168 2892 S 0 0.2 0:00.00 thr_name_0 6643 mmarkk 20 0 180m 6168 2892 S 0 0.2 0:00.00 thr_name_1
Anonymous
I expect that pstree shows thread names for threads instead of process name for each thread. Example shows that "top" utility works correctly.
Line 874 has the problem:
What this does is it takes the command name of the process, puts braces around it and calls it a thread name. This is what we're seeing. What pstree should do is look in /proc/<PID>/task/<TID>/stat for the right command name for the thread.
Pretty easy one to fix, thanks for pointing it out and giving me a test script.
Git commit [9de89a] has the fix for this. The commit shows the before and after behaviour.
Related
Commit: [9de89a]
Last edit: Craig Small 2014-01-31
Hay! you forgot to call fclose() after fopen() in new code (!)
fcloses are in commit [ffc53f], assuming that was the ones you were referring to.
Related
Commit: [ffc53f]