Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Date: Thu, 15 Nov 2001 22:25:27 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: Win98se and using SSHD as a TRUE service Message-ID: <20011115222527.C27452@cygbert.vinschen.de> Mail-Followup-To: cygwin AT cygwin DOT com References: <3BF274A3 DOT D7E5F5DA AT s3group DOT com> <00c901c16d7b$da23f880$0200000a AT dyn DOT ik DOT ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <00c901c16d7b$da23f880$0200000a@dyn.ik.ca>; from GVillemure@ik.ca on Thu, Nov 15, 2001 at 03:18:43AM +0100 On Thu, Nov 15, 2001 at 03:18:43AM +0100, Gerald Villemure wrote: > switch (fork()) { > case -1: > return (-1); > case 0: > break; > default: > #ifdef HAVE_CYGWIN > /* > * This sleep avoids a race condition which kills the > * child process if parent is started by a NT/W2K service. > */ > sleep(1); > > /* > * This is the code that I took from WinVNC > * The best solution would be to enclose this in a IF Win9x > clause > * that is if I knew propers C syntax I could do this > */ > > // Obtain a handle to the kernel library > HINSTANCE kerneldll = LoadLibrary("KERNEL32.DLL"); > if (kerneldll == NULL) > break; > > // And find the RegisterServiceProcess function > DWORD (*RegisterService)(DWORD, DWORD); > RegisterService = (DWORD (*)(DWORD, DWORD)) > GetProcAddress(kerneldll, > "RegisterServiceProcess"); > if (RegisterService == NULL) > break; > > // Register this process with the OS as a service! > RegisterService(NULL, 1); > > > #endif You added the code to the parent's branch. It's the child which has to register as service. Move the code (not the sleep(!)) to the `case 0:' branch, right before the `break;'. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developer mailto:cygwin AT cygwin DOT com Red Hat, Inc. -- 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/