How do i display process threads using ps on linux for a specific task group id?



  • Man page for ps.

           -m     Show threads after processes.
           -l     Long format.  The -y option is often useful with this.
           nwchan      WCHAN     address of the kernel function where the process is sleeping (use
                                 wchan if you want the kernel function name).  Running tasks will
                                 display a dash ('-') in this column.
           tgid        TGID      a number representing the thread group to which a task belongs (alias
                                 pid).  It is the process ID of the thread group leader.
    

    Running ps generally does not show process thread information. Using certain ps options allows you do see thread information.

    $ ps -m -l 7311
    F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY        TIME CMD
    4 -  1000  7311     1  0   -   - - 512447 -     tty2       0:21 /usr/lib/firefox/firefox -new-window
    4 S  1000     -     -  0  80   0 -     - poll_s -          0:11 -
    1 S  1000     -     -  0  80   0 -     - poll_s -          0:00 -
    1 S  1000     -     -  0  80   0 -     - poll_s -          0:00 -
    1 S  1000     -     -  0  80   0 -     - ep_pol -          0:00 -
    1 S  1000     -     -  0  80   0 -     - futex_ -          0:00 -
    1 S  1000     -     -  0  80   0 -     - futex_ -          0:00 -
    1 S  1000     -     -  0  80   0 -     - futex_ -          0:00 -
    1 S  1000     -     -  0  80   0 -     - futex_ -          0:00 -
    1 S  1000     -     -  0  80   0 -     - poll_s -          0:00 -
    1 S  1000     -     -  0  80   0 -     - poll_s -          0:00 -
    1 S  1000     -     -  0  80   0 -     - futex_ -          0:00 -
    

    Another way is

    $ ps -eTl | grep 7311 | less
    F S   UID   PID  SPID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
    4 S  1000  2974  2974  7311  0  80   0 - 385185 poll_s tty2    00:00:00 Web Content
    1 S  1000  2974  2977  7311  0  80   0 - 385185 ep_pol tty2    00:00:00 Chrome_~dThread
    1 S  1000  2974  2978  7311  0  80   0 - 385185 poll_s tty2    00:00:00 gmain
    1 S  1000  2974  2979  7311  0  80   0 - 385185 poll_s tty2    00:00:00 gdbus
    1 S  1000  2974  2989  7311  0  80   0 - 385185 futex_ tty2    00:00:00 JS Watchdog
    1 S  1000  2974  2990  7311  0  80   0 - 385185 futex_ tty2    00:00:00 JS Helper
    1 S  1000  2974  2991  7311  0  80   0 - 385185 futex_ tty2    00:00:00 JS Helper
    1 S  1000  2974  2992  7311  0  80   0 - 385185 poll_s tty2    00:00:00 Socket Thread
    1 S  1000  2974  2993  7311  0  80   0 - 385185 futex_ tty2    00:00:00 Timer
    1 S  1000  2974  2994  7311  0  80   0 - 385185 futex_ tty2    00:00:00 DOM File
    1 S  1000  2974  2995  7311  0  80   0 - 385185 futex_ tty2    00:00:00 Worker Launcher
    1 S  1000  2974  2996  7311  0  80   0 - 385185 futex_ tty2    00:00:00 PaintThread
    1 S  1000  2974  2997  7311  0  80   0 - 385185 futex_ tty2    00:00:00 ImgDecoder #1
    ...
    ...
    ...
    


© Lightnetics 2019