Bash Question: How to get the pid of 2nd terminal tab in 1st terminal tab ?
by Lennard37 from LinuxQuestions.org on (#5SNYE)
Envirement:
* Linux like Ubuntu, Cinnamon desktop, bash, terminal
How to get to get the pid of 2nd terminal tab in 1st terminal tab ?
Follow sample:
Code:echo pid $$; gnome-terminal --title="TAB-Titel" --tab --active -- bash -c "echo $$ & echo Hello; read exec bash"What the sample try to do on this time (dosnt realy work on this time):
* echo the pid of 1st terminal tab on 1st terminal tab
* echo the pid of 2nd terminal tab on 2nd terminal tab
Which functionality I try too get on the end:
* echo the pid of 1st and 2nd terminal tab on 1st terminal tab
* echo the pid of 2nd terminal tab on 2nd terminal tab
Whats wrong with the sample code?
* I am getting wrong pid as echo on 2nd terminal tab.
* I dont know how to output the pid of 2nd terminal tab on 1st terminal tab also.
Any idea how to do ?
The follow are known:
Its known its possible to get the pid of a terminal by:
Code:echo $$Its known its possible to get the pid of a called program by p.e. follow:
Code:xed & $!Its known its possible to show the bash used pids by follow:
Code:ps ax | grep bashIts known its possible to close terminal Tab by follow for testing purposes:
Code:kill -15 123456
* Linux like Ubuntu, Cinnamon desktop, bash, terminal
How to get to get the pid of 2nd terminal tab in 1st terminal tab ?
Follow sample:
Code:echo pid $$; gnome-terminal --title="TAB-Titel" --tab --active -- bash -c "echo $$ & echo Hello; read exec bash"What the sample try to do on this time (dosnt realy work on this time):
* echo the pid of 1st terminal tab on 1st terminal tab
* echo the pid of 2nd terminal tab on 2nd terminal tab
Which functionality I try too get on the end:
* echo the pid of 1st and 2nd terminal tab on 1st terminal tab
* echo the pid of 2nd terminal tab on 2nd terminal tab
Whats wrong with the sample code?
* I am getting wrong pid as echo on 2nd terminal tab.
* I dont know how to output the pid of 2nd terminal tab on 1st terminal tab also.
Any idea how to do ?
The follow are known:
Its known its possible to get the pid of a terminal by:
Code:echo $$Its known its possible to get the pid of a called program by p.e. follow:
Code:xed & $!Its known its possible to show the bash used pids by follow:
Code:ps ax | grep bashIts known its possible to close terminal Tab by follow for testing purposes:
Code:kill -15 123456