Avoid deadlocks in exec plugin.

Attempt to fix collectd/collectd#229 by doing user / group lookups before we fork. Essentially, the problem was that the child process was inheriting the state of various mutexes used by `getpwnam_r` etc., and so if that mutex was locked when the process forked, the child would not be able to re-aquire it, and thus deadlock. A more complete description of the issue is in the referenced ticket. 

It's largely just a cut and paste job--I'm open to refactoring the patch if needs be.