T
trstag75
Hi all,
I'd like to know what is a safe way to deal with
an external process which we're *sure* won't
be generating any output on stdout/stderr nor
expecting any output on stdin.
Do I still need to read the InputStream(s)?
Would there still be a risk of being blocked
during the read?
I'd like to avoid having to create a
new unnecessary thread (once again, it is know
for sure that the process won't generate anything
on stdout/stderr) just for reading a stream that
I know shall be empty.
Basically I'm calling a shell script whose whole
point is that it 'wraps' the command to be called,
redirecting stdout/stderr to files (and also making
sure that it shall not block if the wrapped
command happens to expect input on stdin).
So that very simple shell script I'm calling
cannot generate anything on stdout/stderr.
It is convenient in that it eliminates the potential
deadlocks explained in the Process class's
JavaDoc.
JavaDoc (JD) for the Process class :
JD: Because some native platforms only provide
JD: * limited buffer size for standard input and output streams,
failure
JD: * to promptly write the input stream or read the output stream of
JD: * the subprocess may cause the subprocess to block, and even
deadlock
I've read the JavaDoc for ProcessBuilder and Process
and apparently it doesn't mention if reading the InputStream(s)
is mandatory or not.
Any infos on this?
I'd like to know what is a safe way to deal with
an external process which we're *sure* won't
be generating any output on stdout/stderr nor
expecting any output on stdin.
Do I still need to read the InputStream(s)?
Would there still be a risk of being blocked
during the read?
I'd like to avoid having to create a
new unnecessary thread (once again, it is know
for sure that the process won't generate anything
on stdout/stderr) just for reading a stream that
I know shall be empty.
Basically I'm calling a shell script whose whole
point is that it 'wraps' the command to be called,
redirecting stdout/stderr to files (and also making
sure that it shall not block if the wrapped
command happens to expect input on stdin).
So that very simple shell script I'm calling
cannot generate anything on stdout/stderr.
It is convenient in that it eliminates the potential
deadlocks explained in the Process class's
JavaDoc.
JavaDoc (JD) for the Process class :
JD: Because some native platforms only provide
JD: * limited buffer size for standard input and output streams,
failure
JD: * to promptly write the input stream or read the output stream of
JD: * the subprocess may cause the subprocess to block, and even
deadlock
I've read the JavaDoc for ProcessBuilder and Process
and apparently it doesn't mention if reading the InputStream(s)
is mandatory or not.
Any infos on this?