Fixed synchronization bug when waiting for a process.