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 [EMAIL PROTECTED] (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/