是否可以从函数本身获取后台执行的函数的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
答案 0 :(得分:1)
我想你想要这个:
{{1}}