Corrected wrong handling if PID file couldn`t be resolved.
Added an additional wait call to be sure all children resolving PIDs of a PID file have finished execution and written data.