Added shortcut for executing commands in PTY.
diff --git a/com.google.eclipse.cdt.core/utils/com/google/eclipse/cdt/utils/Processes.java b/com.google.eclipse.cdt.core/utils/com/google/eclipse/cdt/utils/Processes.java
new file mode 100644
index 0000000..13c6f6f
--- /dev/null
+++ b/com.google.eclipse.cdt.core/utils/com/google/eclipse/cdt/utils/Processes.java
@@ -0,0 +1,41 @@
+package com.google.eclipse.cdt.utils;
+
+import org.eclipse.cdt.utils.pty.PTY;
+import org.eclipse.cdt.utils.spawner.ProcessFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * Utility methods related to processes.
+ */
+public final class Processes {
+ /**
+ * Starts a new process.
+ * @param command the command to execute.
+ * @param environment the environment variables.
+ * @param workingDirectory the working directory.
+ * @return the new process.
+ * @throws IOException if something went wrong.
+ */
+ public static Process executeInPty(
+ String[] command, Map<String, String> environment, File workingDirectory) throws IOException {
+ PTY pty = new PTY(true);
+ ProcessFactory processFactory = ProcessFactory.getFactory();
+ return processFactory.exec(command, toArray(environment), workingDirectory, pty);
+ }
+
+ private static String[] toArray(Map<String, String> environmentMap) {
+ List<String> environment = new ArrayList<String>();
+ for (Entry<String, String> entry : environmentMap.entrySet()) {
+ environment.add(entry.getKey() + "=" + entry.getValue());
+ }
+ return environment.toArray(new String[environment.size()]);
+ }
+
+ private Processes() {}
+}