I have no idea how nginx does it, but basically it can just exec new binary file that has a socket to listen to a new process with it (in fact, it remains the same process, it just replaces the executable program with This). The listening socket has a lag in incoming connections, and as long as it loads fast enough, it should be able to start them before overflowing. If not, perhaps it will work first, and then wait until it is ready to process incoming requests, and then send a listening socket command (file descriptors are inherited during forcing, both have access to it) through some internal mechanism, before you go out. Noting your observations, this is similar to what it does (if your parent process dies, your ppid is reassigned to init, i.e. Pid 1)
If it has several processes competing for reception on the same listening socket (again, I donβt know how nginx does it, maybe it has a dispatch process?), Then you can replace them one by one, do a new one program, as indicated above, but one at a time so as to never throw the ball. Please note: during such a process, there will never be any new pid or parent / child changes.
At least, I think, probably, how I would do it, from my head.
source share