Java hangs when trying to close a ProcessBuilder OutputStream

后端 未结 3 1663
旧巷少年郎
旧巷少年郎 2020-12-21 16:58

I have the following Java code to start a ProcessBuilder, open an OutputStream, have the process write a string to an OutputStream, and then close the OutputStream. The who

3条回答
  •  死守一世寂寞
    2020-12-21 17:38

    Do you have anything reading from stdout/stderr of the process ?

    It's quite likely the process tries to output something, but gets blocked since noone is reading the output. Meaning your out.flush() or out.close() blocks as the process can't get around to process the input since its blocked doing output.

提交回复
热议问题