In your example, the child process keeps executing the code outside the if branch. Eventually, all your child processes spawned after a successful accept() end up waiting in another accept() call for more clients and creating more children as they connect. You should probably put an exit() at the end of the if ($pid == 0) branch.