1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 580113: Expose concurrent invocations

The class CommandLauncher holds an internal state of the process and
it's command line. To avoid corrupting the internal state, only allow
executing new commands if the previous command is finished.

Contributed by STMicroelectronics

Change-Id: If41816f6b642953776a4fea3df9f341a17712222
Signed-off-by: Torbjörn Svensson <torbjorn.svensson@st.com>
This commit is contained in:
Torbjörn Svensson 2022-06-03 07:14:55 +02:00 committed by Torbjorn-Svensson
parent a9c3819565
commit 4a1e0f467b

View file

@ -16,6 +16,8 @@ package org.eclipse.cdt.core;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.ConcurrentModificationException;
import java.util.Properties;
import org.eclipse.cdt.internal.core.Cygwin;
@ -161,6 +163,17 @@ public class CommandLauncher implements ICommandLauncher {
@Override
public Process execute(IPath commandPath, String[] args, String[] env, IPath workingDirectory,
IProgressMonitor monitor) throws CoreException {
// Ensure that previous command has finished before launching next.
if (fProcess != null && fProcess.isAlive()) {
String command = "(unknown)"; //$NON-NLS-1$
if (fCommandArgs != null) {
command = Arrays.asList(fCommandArgs).toString();
}
throw new ConcurrentModificationException(
NLS.bind("Process for command \"{0}\" is still executing.", command)); //$NON-NLS-1$
}
parseEnvironment(env);
String envPathValue = getEnvironmentProperty(PATH_ENV);