I need to detect when a process created by IDEA terminates so I can collect coverage data (my own - not EMMA's)
I mean process run as an Application or JUnit (or any other unit test framework), no matter if Run or Debugged.
The most logical tool seems to be to add a ProcessListener to a ProcessHandler.
Queston, though: how to lay hands on one?
One approach I used is to provide a RunConfigurationExtension instance and install a ProcessListener in the handleStartProcess method.
This works fine for Application, but is ignored in case of JUnit run.
Second one was to register a RunContentListener, extract ProcessHandler from RunContentDescriptor in contentSelected method and install the listener there (unless the process is already terminated or the listener is already installed)
This seems to work well for both Application and JUnit, but it depends on the fact that every time there is something written to the console - which seems to be true, but is it guaranteed? (And it generally seems hacky)
Is there any better way to do it?