help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] How to determine the parent's parent (Was: Re: Where doe


From: Chris F.A. Johnson
Subject: Re: [Help-bash] How to determine the parent's parent (Was: Re: Where does $TERM come from?)
Date: Sun, 21 Jun 2015 20:45:26 -0400 (EDT)
User-agent: Alpine 2.10 (DEB 1266 2009-07-14)

On Sun, 21 Jun 2015, Chris F.A. Johnson wrote:

On Sun, 21 Jun 2015, Dennis Williamson wrote:

On Sun, Jun 21, 2015 at 3:57 PM, Andrew Miller <address@hidden> wrote:

Eduardo A. Bustamante López <address@hidden> writes:
If you want to explore the process tree, use a tool like ps:

I'm looking to replace the "case $TERM in..." statement in my bashrc with
something more fine-grained.

Since it runs every time bash is launched, and my machine is a 15-year-old
thinkpad, I'd prefer not to call an external program like ps. That adds a
lot
of overhead.


On a system with /proc:

stat=($(</proc/$$/stat))    # create an array
ppid=${stat[3]}             # get the fourth field

  Command substitution is almost as slow as an external command and
  unnecessary:

read -a stat < /proc/$$/stat

   Or:

read a b c ppid e <  /proc/$$/stat

   Or:

echo "$PPID"

--
Chris F.A. Johnson, <http://cfajohnson.com>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]