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: Dennis Williamson
Subject: Re: [Help-bash] How to determine the parent's parent (Was: Re: Where does $TERM come from?)
Date: Sun, 21 Jun 2015 18:18:24 -0500

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

>From http://stackoverflow.com/a/3587373/26428

Also see the other answer at that link for a function that gets the
ancestral pid (one step below init).

-- 
Visit serverfault.com to get your system administration questions answered.


reply via email to

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