所以我有一个通过 ProcessBuilder 调用 C 程序的 Java 程序,我需要 C 程序在发生某些事情时通知 Java 程序。我有以下java prog代码:
String cmd[] = //string to run the c program in the terminal, no probs here
ProcessBuilder builder = new ProcessBuilder(cmd);
builder.redirectErrorStream(true);
Process process = builder.start();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
System.out.println(bufferedReader.ready());
System.out.println(bufferedReader.readLine());
在给定点的 c 程序必须通知 java 程序一些事情。我尝试了很多事情,比如
char Buff[] = "output";
write(0, Buff, strlen(Buff)+1);
write(1, Buff, strlen(Buff)+1);
printf("output\n");
但我无法让 java 程序读取这个,我得到的唯一输出是
false
null