Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It is possible for C programs to update themselves with zero downtime. See nginx[1], "Upgrading Executable on the Fly". The trick is that fork()'ed processes (can) inherit open sockets from their parent, even after exec()'ing a new binary. This seems a bit delicate and involves some communication during the hand-off from the old to the new, but it does work. It's also possible to kill the "new" if there were any problems and instruct the "old" to take over again.

This is not to take anything away from Erlang, which is a very interesting system.

[1] http://www.nginx.org/en/docs/control.html



> This seems a bit delicate and involves some communication during the hand-off from the old to the new, but it does work.

MUDs routinely did this back in the day. Here's a README excerpt from Erwin Andreasen's widely used patch:

"Basically, for each playing descriptor, it saves the descriptor number, the player's original name as well as the host name (so we don't have to find that again). Then, it closes fpReserve, and exec's the MUD again. As exec preserves open file descriptors, players do not lose link. The MUD is executed with some extra parameters, so the new copy knows that it should reload some player files. It does that, and puts in the players at their old places."

http://www.andreasen.org/ftp/copyover-7.tar.gz


Just logged in to say this is the most awesome thing I've read in weeks. Why did I not know this earlier?!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: