delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/11/13/10:57:17

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Sun, 13 Nov 2005 16:57:06 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: cygrunsrv hangs forever on exec error (fix included)
Message-ID: <20051113155706.GB3462@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <43761BF8 DOT 9030603 AT t-online DOT de> <20051113131927 DOT GA3462 AT calimero DOT vinschen DOT de> <437751C0 DOT 0 AT t-online DOT de>
Mime-Version: 1.0
In-Reply-To: <437751C0.0@t-online.de>
User-Agent: Mutt/1.4.2i

On Nov 13 15:46, Christian Franke wrote:
> Corinna Vinschen wrote:
> >Thanks for this report and the simple testcases.  The description
> >is very helpful.  I just don't really like the idea to leave the
> >service_main function through _exit.
> 
> Agree. But this is IMO the only way to let SCM automatically restart a 
> failed service if desired.
> A nonzero exitcode does not help, the process(!) must die prematurely 
> without setting SERVICE_STOPPED.
> 
> I found all this via trial and error when adding service support to a 
> legacy MFC app.
> So this info might be incomplete and not "portable" to anything except XP.

Restarting a service is only available since W2K anyway, isn't it?
In theory, this behaviour shouldn't affect W2K negatively.

> >I didn't create a new cygrunsrv version for now, instead I'm sending
> >my diff.  I would like to hear what you think and if I didn't made a
> >fatal mistake, I'll uplaod a new cygrunsrv version with this changes.
> 
> Patch looks OK (no time to really test now sorry), structure now much 
> cleaner.
> It should avoid the hang - except in the neverexists case.
> 
> In this case, service_main() still exits without setting SERVICE_STOPPED 
> and SCM will waitforever for some thread doing this.
> (Yes, SCM should check the thread count, but it doesn't)
> 
> Suggest ugly but possibly working:
> 
>      if (neverexits && !shutting_down)
>        {
>          syslog (LOG_ERR, "`%s' service exited prematurely with "
>              "exit status: %u", svcname, s);
>          /* Do not report that the service is stopped so that if
>         recovery options are set, Windows will automatically
>         restart the service. */
>          service_main_exitval = s;
> +         _exit(service_main_exitval);
>        }

Ok, convinced.  I added an _exit at this point.  I still don't think
the sleep in main is necessary, though.  I've uploaded cygrunsrv-1.11,
which contains these patches.


Thanks again,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019