Skip to content

Commit 22122f0

Browse files
committed
Launch xpm in a PTY
By launching in a PTY the `bash -i` won't have its stdin connected to the stdin of Eclipse, meaning it will properly behave and not stop with a SIGTTIN when bash tries to read. Fixes #626
1 parent 581648c commit 22122f0

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

plugins/org.eclipse.embedcdt.core/src/org/eclipse/embedcdt/core/EclipseUtils.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
3131
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
3232
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
33+
import org.eclipse.cdt.utils.pty.PTY;
34+
import org.eclipse.cdt.utils.pty.PTY.Mode;
3335
import org.eclipse.cdt.utils.spawner.ProcessFactory;
3436
import org.eclipse.core.resources.IProject;
3537
import org.eclipse.core.resources.ProjectScope;
@@ -522,7 +524,12 @@ public static String[] getShellEnvironment() {
522524
List<String> outputLines = new ArrayList<>();
523525
try {
524526
BufferedReader reader = null;
525-
Process process = ProcessFactory.getFactory().exec(cmdArray, envp);
527+
Process process;
528+
if (PTY.isSupported(Mode.TERMINAL)) {
529+
process = ProcessFactory.getFactory().exec(cmdArray, envp, null, new PTY(Mode.TERMINAL));
530+
} else {
531+
process = ProcessFactory.getFactory().exec(cmdArray, envp);
532+
}
526533
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
527534

528535
String line;

plugins/org.eclipse.embedcdt.templates.core/src/org/eclipse/embedcdt/templates/core/processes/ConditionalRunCommand.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
2727
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
2828
import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
29+
import org.eclipse.cdt.utils.pty.PTY;
30+
import org.eclipse.cdt.utils.pty.PTY.Mode;
2931
import org.eclipse.cdt.utils.spawner.ProcessFactory;
3032
import org.eclipse.core.resources.IProject;
3133
import org.eclipse.core.resources.IResource;
@@ -150,7 +152,12 @@ public void process(TemplateCore template, ProcessArgument[] args, String proces
150152

151153
try {
152154
BufferedReader reader = null;
153-
Process process = ProcessFactory.getFactory().exec(cmdArray, envp, dir);
155+
Process process;
156+
if (PTY.isSupported(Mode.TERMINAL)) {
157+
process = ProcessFactory.getFactory().exec(cmdArray, envp, dir, new PTY(Mode.TERMINAL));
158+
} else {
159+
process = ProcessFactory.getFactory().exec(cmdArray, envp, dir);
160+
}
154161
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
155162

156163
String line;

plugins/org.eclipse.embedcdt.ui/src/org/eclipse/embedcdt/ui/templates/core/processes/ConditionalRunCommandUi.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
1414
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
1515
import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
16+
import org.eclipse.cdt.utils.pty.PTY;
17+
import org.eclipse.cdt.utils.pty.PTY.Mode;
1618
import org.eclipse.cdt.utils.spawner.ProcessFactory;
1719
import org.eclipse.core.resources.IProject;
1820
import org.eclipse.core.resources.IResource;
@@ -150,7 +152,12 @@ public void run(IProgressMonitor pm) throws InterruptedException {
150152
try {
151153
BufferedReader reader = null;
152154
pm.worked(1);
153-
Process process = ProcessFactory.getFactory().exec(cmdArray, envp, dir);
155+
Process process;
156+
if (PTY.isSupported(Mode.TERMINAL)) {
157+
process = ProcessFactory.getFactory().exec(cmdArray, envp, dir, new PTY(Mode.TERMINAL));
158+
} else {
159+
process = ProcessFactory.getFactory().exec(cmdArray, envp, dir);
160+
}
154161
pm.worked(1);
155162
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
156163

0 commit comments

Comments
 (0)