public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Win98se and using SSHD as a TRUE service
Date: Sun, 11 Nov 2001 08:26:00 -0000	[thread overview]
Message-ID: <20011115222527.C27452@cygbert.vinschen.de> (raw)
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@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/

  parent reply	other threads:[~2001-11-15 21:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-11  8:26 JAmes Coleman
2001-11-11  8:26 ` Gerald Villemure
2001-11-11  8:26   ` JAmes Coleman
2001-11-11  8:26     ` Gerald Villemure
2001-11-11  8:26   ` Corinna Vinschen [this message]
2001-11-11  8:26     ` Win98se and using SSHD as a TRUE service (solution) Gerald Villemure
  -- strict thread matches above, loose matches on Subject: below --
2001-11-11  8:26 Win98se and using SSHD as a TRUE service GregHolmes
2001-11-08 21:04 Gerald Villemure
2001-11-09  5:34 ` Max Bowsher
2001-11-09 10:26   ` Gerald Villemure

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011115222527.C27452@cygbert.vinschen.de \
    --to=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).