Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <3C587F40.FB1EED18@lapo.it> Date: Thu, 31 Jan 2002 00:18:24 +0100 From: Lapo Luchini X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U) X-Accept-Language: it,en,fr,es,ja MIME-Version: 1.0 To: chuckm AT rochester DOT rr DOT com CC: cygwin AT cygwin DOT com Subject: Re: Cygwin port of rsync -- patch for Win2k (rsync 2.5.1) References: <3C581EC5 DOT 20100 AT rochester DOT rr DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I don't think I have enough knowledge on the "fork() in cygwin" subject to evaluate if there are better solutions, I reply also in the mailing list. Lapo BTW: I'll try the fix soon, just wanted some more "advice from the gurus" about the issue ;) Chuck Messenger wrote: > Hi Lapo, > > I've been trying out the Cygwin port of rsync -- version 2.5.1. I've > found that it doesn't work in server (i.e. --daemon) mode on my Win2k > box, but it does work on my Win98 box. > > I did some debugging, and came up with a fix. > > In socket.c, we have the following code which the server executes after > being connected to by a client: > > if (fork()==0) { > close(s); > /* open log file in child before possibly giving > up privileges */ > log_open(); > _exit(fn(fd)); > } > > >>> delay(1); /* CHM addition */ > > close(fd); > > I've marked my addition with >>>. What seems to happen on Win2k is that > the close(fd) gets called by the mother process before the child process > gets going. By adding a 1 second delay after the fork in the mother > process, it seems to give enough time for the child to replicate the > socket, so the mother can safely close(fd) it. > > The code for delay is: > > static void /* CHM addition */ > delay( > int secs) > { > struct timeval timeout; > > timeout.tv_sec = secs; > timeout.tv_usec = 0; > > select(0, NULL, NULL, NULL, &timeout); > } > > I've been running rsync with this mod, and it seems to work fine. > > I know it's ugly -- the real solution would be to fix fork() -- but at > least it works... > > - Chuck -- Lapo 'Raist' Luchini lapo AT lapo DOT it (PGP & X.509 keys available) http://www.lapo.it (ICQ UIN: 529796) -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/