This is the mail archive of the cygwin 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: cygrunsrv hangs forever on exec error (fix included)

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 Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat, Inc.

Unsubscribe info:
Problem reports:

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