Skip to content

Commit

Permalink
stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7d8 committed Aug 15, 2024
1 parent 9e63aeb commit a047b94
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ public void startServer(String[] cmd) throws ServerStartupException {
}
}).start();

new Thread(() -> {
try (BufferedReader userInputReader = new BufferedReader(new InputStreamReader(System.in))) {
String userInput;
while ((userInput = userInputReader.readLine()) != null) {
processHolder.writer.write(userInput + "\n");
processHolder.writer.flush();
}
} catch (IOException e) {
e.printStackTrace();
}
}).start();

Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (processHolder.process != null && processHolder.process.isAlive()) {
try {
Expand Down

0 comments on commit a047b94

Please sign in to comment.