title: upgrade server executable without losing user's connections
body: <p>I need to develop a mechanism to upgrade a running daemon in production environment to a new version without losing client's (TCP) connections. Something similar to what nginx does when you upgrade it to a new version. I need this for bug removal or to release minor version changes, which may be once a day. The daemon is developed in C for Linux platform. </p>
  
  <p>The process for the upgrade would be like this:</p>
  
  <ol>
  <li>The new_daemon would be ran from the command line specifying the process id of the old_daemon</li>
  <li>The new_daemon would connect via socket to the old daemon to send/receive data and mesages.</li>
  <li>The new_daemon would send the old_daemon a message to stop listening on the <em>PORT</em> which is used to receive client's connections. After confirming the detention of the listening service, the new_daemon would start listening on <em>PORT</em></li>
  <li>The new_daemon would send the message to old_daemon to send currently open file descriptors of the user's connections. Using the system call sendmsg() the old_daemon would pass the new_daemon all resources it has allocated with the kernel, not only the connections, but also all open files.</li>
  <li>The new_daemon would send the message to old_daemon to pass all global memory variables and the old_daemon would send it over the socket connection between both processes.</li>
  </ol>
  
  <p>This process is very complex, so I would like to ask if someone can suggest a better process or maybe there is some methodology to do this easily? The goal is to have the least downtime during the upgrade process.</p>
  
  <p>TIA</p>