【发布时间】:2016-04-28 10:18:28
【问题描述】:
是否可以从函数本身获取后台执行的函数的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
【问题讨论】: