0
是否有可能從函數本身獲取在後臺執行的函數的PID?獲取在後臺執行的函數的pid
#!/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