Jacobs2000
Jacobs2000

Reputation: 938

Prunsrv exe killed via task manager but child process remains

I have a Java application run as a Windows service using procrun (specifically prunsrv). The service is defined as an exe StartMode so a batch file (run-my-app.bat) is run as the StartImage. Why I am not using jvm or java mode is a different story, not related to this issue (I was unable to run spring boot application with procrun, all examples did not work so I resorted to creating a batch file and calling java -jar my.jar). prunsrv.exe is actually renamed according to the application, say myapp.exe. The problem is that if myapp.exe is killed via the task manager, the java process remains! The batch file run-my-app.bat runs the application using the following line:

start "%APP_NAME%" /b "%JAVA_EXE%" -jar myapp.jar --spring.config.location=application.properties --logging.config=log4j2.xml

The batch file completes and the started Java process remains - I know this because if I print a message after the above "start" command I see the message in the log.

Is there any way to stop the java process when the prunsrv.exe (renamed myapp.exe) is killed?

Upvotes: 0

Views: 512

Answers (1)

Thomas Weller
Thomas Weller

Reputation: 59409

Child processes will only be closed if they were created as Job objects.

IMHO it's not possible to tell prunsrv.exe to start processes as jobs, so the answer to your question is No.

You can of course terminate every single process individually. There are attempts to kill process trees, but be aware that Windows does not maintain parent-child-relationships. That means: If in a chain of 3 processes the middle one dies, the tree is not available any more.

Upvotes: 0

Related Questions