pstree details on command output

I have one terminal window open and enter superuser mode.

#pstree -hp | grep konsole
           |                |-konsole(12888)-+-bash(12891)---su(14410)---bash(14413)-+-grep(14463)
           |                |                |-{konsole}(12889)
           |                |                `-{konsole}(12890)

I need to understand the details in this output. First, why are there more than one kconsole? Second, the details of the connections here, break it down.

FYI, I’m learning scripting as write code.

Thanks.

From

man pstree

Child threads of a process are found under the parent process and are shown with the process name in curly braces, e.g.

icecast2---13*{icecast2}]

BTW, do you ever read man pages before you come here?

PS.
Apparently xterm does not use threading. Thus when this confuses you, you could use xterm instead of konsole (or maybe another terminal emulator).

In the Konsole window, you could have simply hit F11 and then, executed “pstree -hp” …

  • On this system Akonadi and Firefox and MariaDB all have a number of processes running …
  • “ps -ejH -u «your username»” will also output your process trees …

[HR][/HR]Understanding UNIX® and Linux processes is part of the Process Management skill needed by System Programmers.

  • Yes, UNIX® and Linux System Administrators also need some Process Management knowledge but, not to the same depth.
  • The Linux Foundation Certified System Administrator (LFCS) material has this entry: <https://www.linux.org/threads/lfcs-linux-process-management.28779/&gt;.
  • There are also commercial tutorials explaining Linux processes – simply search for “Linux Process Managment” in DuckDuckGo …

[QUOTE=hcvv;2936907]From

man pstree

BTW, do you ever read man pages before you come here?

Yes and often online pages. The manual pages are often not enough. Programmers and script writers often not great at writing docs, including myself. :wink:

I admit that a man page is not a good documentation about a product, but most descibe in formal language waht it does and what options exist. And what I showed you was simply to be found there. My questions is of course: why could I find that in two minutes where you failed to see it?

Hi
You might want to look at pidof as well…


pstree -hp `pidof tilda`

tilda(2016)─┬─bash(16952)───pstree(30340)
            ├─bash(27996)
            ├─bash(30163)
            ├─{tilda}(2084)
            ├─{tilda}(2088)
            └─{tilda}(30164)

The above tells me I have tilda running and three subprocesses which indicate three tabs open, it will disappear since the process may sleep…

If your wanting to control a script, look at run options and creating a pid file…

This is one I use for starting/stopping virtualradar (ADSB tracking);


cat bin/virtualradar

#!/bin/bash

# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# Copyright (C) 2018-2020 Malcolm Lewis <malcolmlewis@opensuse.org>

# Description: Script to start the Virtual Radar Service
# Version: 0.0.1
# Date: 11th February, 2018

case "$1" in
    start)
        test ! -f /tmp/vrs.lock || { echo "Virtual Radar is already running...";
       if  "$1" = "stop" ]; then exit 0;
       else exit 6; fi; }
        VRS_START=`date +\%m%d%y%H%M%S`
        echo "========" $VRS_START "========" > /tmp/virtualradar.log
        /usr/bin/mono /data/applications/VirtualRadar/VirtualRadar.exe -nogui >> /tmp/virtualradar.log &
    echo "** Success, Virtual Radar has been started and lockfile created... **"
        lockfile -r 0 /tmp/vrs.lock
    ;;
    stop)
        test -f /tmp/vrs.lock || { echo "Virtual Radar is already stopped...";
       if  "$1" = "stop" ]; then exit 0;
       else exit 6; fi; }
        VRS_PID=`pgrep -f VirtualRadar.exe`
        kill -n 9 $VRS_PID
    rm -f /tmp/vrs.lock
    echo "Virtual Radar stopped..."
    ;;
       *)
    echo "Usage: $0 {start|stop}"
    exit 1
    ;;
esac

The original UNIX® man pages were written by Bell Labs scientists, who were used to writing research papers for publication by organisations such the IEEE …

  • Yes, the text often has to be read as if it is a scientific paper – which is not easy for the non-scientists on this planet – IOW: the majority …