This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Win98se and using SSHD as a TRUE service


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@cygwin.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]