help-bash
[Top][All Lists]
Advanced

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

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


From: Eduardo A . Bustamante López
Subject: [Help-bash] How to determine the parent's parent (Was: Re: Where does $TERM come from?)
Date: Sun, 21 Jun 2015 12:02:34 -0500
User-agent: Mutt/1.5.23 (2014-03-12)

On Sun, Jun 21, 2015 at 03:50:36AM +0000, Andrew Miller wrote:
[...]
  > Does bash save the ancestral PID somewhere?
  > 
  > To explain what I mean, this works:
  > 
  > $ readlink /proc/$PPID/exe
  > /usr/bin/tmux
  > $ echo $TERM
  > screen
> 
> But this doesn't:
> 
> $ sudo bash
> # readlink /proc/$PPID/exe
> /usr/bin/sudo
> # echo $TERM
> screen

Why didn't you post this in a new thread? It has no relevance to the original
one.

And no, it does work. 'sudo' is a process just like the rest. If you run 'sudo
bash', 'sudo' will be bash's parent. If you want to explore the process tree,
use a tool like ps:

address@hidden:~$ ps -p $PPID -o pid= -o ppid= -o args=
 8952  8040 mksh
address@hidden:~$ ps -p $(ps -p $PPID -o ppid=) -o pid= -o ppid= -o args=
 8040  8038 zsh
address@hidden:~$ ps -p $$ -o pid= -o ppid= -o args=
 8964  8952 bash

-- 
Eduardo Bustamante
https://dualbus.me/



reply via email to

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