后台一直报这个错:
22:23:01,264 ERROR [STDERR] java.io.IOException: Bad file descriptor
22:23:01,264 ERROR [STDERR] at java.io.FileInputStream.readBytes(Native Method)
22:23:01,265 ERROR [STDERR] at java.io.FileInputStream.read(FileInputStream.java:220)
22:23:01,265 ERROR [STDERR] at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
22:23:01,265 ERROR [STDERR] at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
22:23:01,265 ERROR [STDERR] at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
22:23:01,265 ERROR [STDERR] at java.io.InputStreamReader.read(InputStreamReader.java:167)
22:23:01,265 ERROR [STDERR] at java.io.BufferedReader.fill(BufferedReader.java:136)
22:23:01,265 ERROR [STDERR] at java.io.BufferedReader.readLine(BufferedReader.java:299)
22:23:01,265 ERROR [STDERR] at java.io.BufferedReader.readLine(BufferedReader.java:362)
22:23:01,265 ERROR [STDERR] at com.hisun.cmf.utils.MkmRequestUtil$1.run(MkmRequestUtil.java:45)
源码是 Process process = Runtime.getRuntime().exec(cmd);
try {
final InputStream is_std = process.getInputStream();
final InputStream is_error = process.getErrorStream();
new Thread() {
@Override
public void run() {
BufferedReader br2 = new BufferedReader(new InputStreamReader(is_error));
try {
String line2 = null;
while ((line2 = br2.readLine()) != null) {
if (line2 != null) {
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is_error.close();
} catch (IOException e) {
e.printStackTrace();
}
}![图片描述][1]
}
}.start();
BufferedReader br1 = new BufferedReader(new InputStreamReader(is_std, "UTF-8"));
try {
String line1 = null;
while ((line1 = br1.readLine()) != null) {
if (line1 != null) {
result = result + line1;
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is_std.close();
} catch (IOException e) {
e.printStackTrace();
}
}
process.waitFor();
} catch (Exception e) {
e.printStackTrace();
} finally {
process.getErrorStream().close();
process.getInputStream().close();
process.getOutputStream().close();
process.destroy();
}
调用linux指令 然后启动一个线程读取错误流的时候报错 请各位大佬帮忙看下,这是什么原因。
上面是报错的代码行
Bad file descriptor
是权限问题,你错误栈里提示的是MkmRequestUtil.java:45
但是看不出你贴的代码究竟错误是在
is_std
还是is_error
,不过应该都是权限问题。