Ajout de l'héritage des entrées/sorties dans CommandExecutor + Ajout du test 11
This commit is contained in:
@@ -37,31 +37,9 @@ public class CommandExecutor {
|
||||
}
|
||||
if (debug) System.out.println("Debug: Executing " + command);
|
||||
ProcessBuilder pb = new ProcessBuilder("sh", "-c", command);
|
||||
pb.inheritIO();
|
||||
Process process = pb.start();
|
||||
|
||||
// Lire et afficher la sortie standard (stdout)
|
||||
new Thread(() -> {
|
||||
try (var reader = new java.io.BufferedReader(new java.io.InputStreamReader(process.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
|
||||
// Lire et afficher la sortie d'erreur (stderr)
|
||||
new Thread(() -> {
|
||||
try (var reader = new java.io.BufferedReader(new java.io.InputStreamReader(process.getErrorStream()))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.err.println(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
|
||||
// Attendre la fin du processus
|
||||
int exitCode = process.waitFor();
|
||||
|
Reference in New Issue
Block a user