In fact exec() already returns the process Id of the created process. This is undocumented, but it should work - try it.