Read from another process' output stream

后端 未结 2 1862
礼貌的吻别
礼貌的吻别 2021-01-21 21:59

i wanted to read the output-stream of a c-Application in my Java program. iremoted (available here: http://osxbook.com/software/iremoted/download/iremoted.c) is a C-App

相关标签:
2条回答
  • 2021-01-21 22:36

    stdout is buffered and it's not automatically flushed if you are not writing to screen. Add:

    fflush(stdout);
    

    after:

    printf("%#lx %s\n", (UInt32)event.elementCookie,
        (event.value == 0) ? "depressed" : "pressed");
    
    0 讨论(0)
  • 2021-01-21 22:37

    iremoted is likely writing to stderr if a hello world program works. You would want the error stream in that case. I'm not sure how this works for your hello world case - I think you're doing the wrong thing here:

     new InputStreamReader(process.getInputStream()); 
    

    should be

     new InputStreamReader(process.getOutputStream());
    

    or

     new InputStreamReader(process.getErrorStream());
    
    0 讨论(0)
提交回复
热议问题