The following started as a bug on embed cdt here: eclipse-embed-cdt/eclipse-plugins#626
When launching bash in interactive mode to run a command, on Ubuntu 24.04 and if Eclipse was launched from a terminal, the bash process hangs.
Consider this code:
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.junit.jupiter.api.Test;
public class ProcessFactoryTest {
@Test
public void testInteractiveShell() throws IOException {
String[] cmd = { "/bin/bash", "-i", "-c", "/bin/echo echome" };
Process process = ProcessFactory.getFactory().exec(cmd, null);
var reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
List<String> outputLines = new ArrayList<>();
while ((line = reader.readLine()) != null) {
outputLines.add(line);
}
assertEquals(List.of("echome"), outputLines);
}
}
If you run this test from an Eclipse started from a terminal, the readLine hangs because the process hangs. If you start Eclipse from the launcher (or file manager) the readLine succeeds.
If you remove the -i then bash starts fine and the test passes.
I have spent some time trying to understand what is different about Eclipse/Linux/anything between when Eclipse starts in the terminal vs the file manager and have tried removing all those differences and still cannot get the -i version to work when launched from the terminal - or to fail when launched from the file manager.
Additional info, csh works, but dash and zsh fail in the same way as bash.
The next step is probably to attach to bash to see why it is hanging.
The following started as a bug on embed cdt here: eclipse-embed-cdt/eclipse-plugins#626
When launching bash in interactive mode to run a command, on Ubuntu 24.04 and if Eclipse was launched from a terminal, the bash process hangs.
Consider this code:
If you run this test from an Eclipse started from a terminal, the readLine hangs because the process hangs. If you start Eclipse from the launcher (or file manager) the readLine succeeds.
If you remove the
-ithen bash starts fine and the test passes.I have spent some time trying to understand what is different about Eclipse/Linux/anything between when Eclipse starts in the terminal vs the file manager and have tried removing all those differences and still cannot get the
-iversion to work when launched from the terminal - or to fail when launched from the file manager.Additional info,
cshworks, butdashandzshfail in the same way asbash.The next step is probably to attach to bash to see why it is hanging.