1. 7

  2. 3

    This is very cool, though a word of caution. Overriding system calls tends to be fragile in unexpected ways. It’s a great technique to achieve various degrees of magic however, when you want to keep unruly apps or libraries inline. I’ve done something similar to avoid patching 3rd party libraries whose native file handling code didn’t interact well with network file systems. It took a long time to get right on every platform. Of course, if you’re using a tool like this, as opposed to shipping it, you care about your platform and a lot less about compatibility on every platform.

    There is probably a place in the world for a library that facilitates fd handoff and restarting. Once that code is written, it’s only a few lines in main() to switch between calling listen() vs accept() on an inherited fd.

    1. 1

      This looks great but worried whether the benefit of zero downtime restart outweighs the risk of inserting untested software into a long-running process.