final ILaunch launch,
IProgressMonitor monitor) throws CoreException {
DebugPlugin.getDefault().addDebugEventListener(new IDebugEventSetListener() {
public void handleDebugEvents(DebugEvent[] events) {
for (int i = 0; i < events.length; i++) {
DebugEvent event = events[i];
Object source = event.getSource();
// check event type
if (event.getKind() == DebugEvent.TERMINATE && source instanceof IProcess) {
IProcess process = (IProcess) source;
// check process
if (launch == process.getLaunch()) {
// remove debug events listener
DebugPlugin.getDefault().removeDebugEventListener(this);