-3

Yes - this concerns the question which commands in terminal are possible, for to find out which programs are initialized (visible and non-visible) - by program1. (for example - when I only want to know, which programs are running by program1 only with name "crash-handler"?) I dont mean this here:

Step 1:

top

And then step 2:

sudo kill -9 PID 'number-of-process'

I mean for to list all programs, which are running by program1 (even hidden processes ... ). This question will be rewarded with bounty! (because of thunderstorm I had amnesia and wanted to put this question earlier - this then would have prevented the stupid "hoaxes" about so-called "shell-shock-vulnerabilities" and else news ... ).

How many possible commands would be out here for this ?! (- not only htop and top and pstree ... ) - thank you !

dschinn1001
  • 3,863

2 Answers2

3

Try htop:

sudo apt-get install htop
htop

It has a tree view (F5) and can show all user and kernel threads (shift+H and shift+K).

Tuomas
  • 131
1

If I understand your question correctly, you want the various ways that can list the child processes of a given process. To my knowledge these are:

  1. top. Launch top and then press V. From man top:

     ´V' :Forest-View-Mode toggle
          In  this  mode,  processes are reordered according to their
          parents and the layout of the COMMAND column resembles that
          of  a  tree.   In  forest view mode it is still possible to
          toggle between program name and commamd line (see  the  'c'
          interactive  command) or between processes and threads (see
          the 'H' interactive command).
    
  2. htop. This is usually not installed by default, so install using sudo apt-get install htop. Then, press F5 or t. From man htop:

    F5, t
        Tree view: organize processes by parenthood, and layout the  rela‐
        tions between them as a tree. Toggling the key will switch between
        tree and your previously selected sort view. Selecting a sort view
        will exit tree view.
    
  3. pstree. This simple command is designed for exactly that, it shows running processes as a tree.

  4. ps itself can also do this. For example:

    $ ps -ejH
    $ ps axjf
    

    The important options here are -H for tree format and/or -f for full format.

  5. You can also get all of this from the /proc filesystem if you feel like it. The children of PIDX are listed in /proc/PIDX/task/PIDX/children. So, you could show a tree of all running processes using

    ps ax | awk '{print $1}' | while read pid; do 
        printf "%s\n" $pid; 
        grep -o "[0-9]*" "/proc/$pid/task/$pid/children" 2>/dev/null | 
            while read cpid; do 
                printf "  |--%s\n" $cpid; 
            done
    done
    

    This is quite silly though since it is reinventing the wheel. Just use one of the approaches above.

terdon
  • 104,119