[
https://issues.apache.org/jira/browse/DAEMON-477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18056400#comment-18056400
]
Mark Thomas commented on DAEMON-477:
------------------------------------
Thanks. A PR would be very helpful.
Freeing the console if one is attached looks reasonable to me. A quick review
of the FreeConsole() documentation suggests that this should be harmless if
there is no console. I do think there needs to be some error handling for
FreeConsole() that logs any errors.
> Problem stopping Windows service in exe mode
> --------------------------------------------
>
> Key: DAEMON-477
> URL: https://issues.apache.org/jira/browse/DAEMON-477
> Project: Commons Daemon
> Issue Type: Bug
> Components: prunsrv
> Affects Versions: 1.5.0
> Reporter: Alexander Pinčuk
> Priority: Major
>
> I want to run a Java server app as a service. Application launch is
> controlled by a batch script. Everything works as expected except for the
> service stopping. The server app itself stops without any problems. But the
> Windows service continues to wait and stops only after StopTimeout seconds.
>
> This happens because prunsrv is waiting for conHost, to which it is attached,
> to complete.
>
> If you detach prunsrv from the console, everything starts works fine. From
> prunsrv.c:
>
> if (!apxDestroyJvm(timeout)) {
> /* if we are not using JAVA apxDestroyJvm does nothing, check the
> chid processes in case they hang */
> apxLogWrite(APXLOG_MARK_DEBUG "apxDestroyJvm did nothing or
> failed");
> *FreeConsole();*
> for (; ; ) {
> if (!apxProcessTerminateChild( GetCurrentProcessId(), TRUE))
> { /* Just print the children processes once for debugging
> */ if (btimeoutelapsed) break;
> waited = waitedSinceStopCmd(); if
> (waited >= timeout) break; /* Done */
> Sleep(1000); }
> else
> { break; }
> }
> }
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)