2016-04-28 9 views
0

Ist es möglich, PID der Funktion im Hintergrund von der Funktion selbst ausgeführt zu bekommen?Get PID der Funktion im Hintergrund ausgeführt

#!/bin/bash 

Foo() 
{ 
    echo PId=$$ #I want pid of process that executed the function! 
} 

echo Main PID=$$ 


Foo & #execute function in background 
echo SUBPID=$! #get the pid of last executed background process, in this case Foo 

wait 

Antwort

1

Ich glaube, Sie dies wünschen:

Foo() 
{ 
    echo $PPID # pid of process that executed the function 
} 
Verwandte Themen