I am encountering some weird behavior when calling a shell script from a Java process.
Process p = Runtime.getRuntime().exec("mybashscript.sh");
(new StreamGobblerThread(p.getInputStream())).start();
(new StreamGobblerThread(p.getErrorStream())).start();
p.waitFor();
returnValue = p.exitValue();
The StreamGobblerThread just has a run() method that does a
while(((inputStream.available>0) { inputStream.skip(available); }
About 20% of the time this works, but mostly the script fails with a return code of 141 right away.
From what I found on google, 141 is a return code when a SIGPIPE was received.
Any ideas?