On 18 Apr 2003 at 17:40, Praise wrote: From: Praise <praisetazio@tiscalinet.it> To: suse-programming-e@suse.com Date sent: Fri, 18 Apr 2003 17:40:37 +0200 Subject: [suse-programming-e] A question on passing descriptors between processes (in C)
Hi all!
I am writing a little irc-like server to learn unix programming in C. As a cool excercise, I would like to do a way to make my program upgrade without any downtime. So here it is my idea:
First process: loader This is not the part of the server which must be upgraded. The only thing to do is getting a deamon, then forking and execing the real server. Then sleeping until a signal awakes it to fork and exec the next (upgraded) server.
Second process: the server It must be upgraded. It does the real job, handles connections and so on. It handles also the downloading of the upgraded server. It works until it receives a signal that put it in the "greeting mode" which I describe below.
Third process: the upgraded server It does the real job, but first he must have all data and socket descriptors from the "Second process", so it starts in "coming mode".
The greeting and coming modes are those when the data (and socket descriptors) exchange occur. I am thinking about unix domain sockets to make socket descriptors and data pass (as described in Stevens' book, the first one on network programming). So, this is my question: there is a simpler way to do that? Is my idea good?
Praise
As far as I know the process described in Stevens book is the standard way of transferring socket descriptors in cases where you have unrelated processes. However with if you had the old server fork() the new one, then the new one would inherit all the descriptors from the old server :) alan -- http://www.ibgames.net/alan Registered Linux user #6822 http://counter.li.org Winding Down - Weekly Tech Newsletter - subscribe at http://www.ibgames.net/alan/winding/mailing.html