title: How to fork properly within an nginx/php-fpm environment?
body: <p>I have a very simple php socket server that runs on my machine.  I created a convinience class with simple methods like "restart" and "stop" and etc. to control the server once it is already running.</p>
  
  <p>What the restart function does is it sends the server the command to stop and then it forks the process and starts a new instance of the socket server within the child process while the parent process returns to the caller.  </p>
  
  <p>This works great on the command line, however I am trying to make an admin webpage which restarts the socket server and the forking is causing problems in php-fpm.  Basically, what it appears is happening is that the life of the "page loading" is not ending when the parent process ends and nginx/php-fpm are not reassigning the process to new connections until the forked process also ends.</p>
  
  <p>In my case, I do not want the forked process to ever end, and I end up with a completely debilitated server.  (in my test environment, for simplicity i have the worker pool set to only 1, in a production environment this will be higher, but this issue would lead to one worker slot being permanently occupied).</p>
  
  <p>I have tried a few things including calling <code>fastcgi_finish_request()</code> just prior to the forking, however this had no affect.</p>
  
  <p>How can I restart my service from a php-fpm worker process without locking up an assignment in the nginx connection pool?</p>