Open GoogleCodeExporter opened 9 years ago
Did you find a solution to this problem? I'm experiencing it too, but only
when run from the python subprocess module.
uname: Linux brasil 2.6.28-18-generic #60-Ubuntu SMP Fri Mar 12 04:40:52 UTC
2010 i686 GNU/Linux
cpu: GenuineIntel Pentium(R) Dual-Core CPU T4200 @ 2.00GHz
distro: xubuntu jaunty
python: 2.6.2
Here's a code snippet showing how I'm running it:
p = subprocess.Popen(cmd, shell=True)
retval = p.wait()
and cmd looks like this:
/usr/local/bench/unixbench-5.1.2/Run context1 >
/usr/local/bench/archive/2010-06-07_08:53:55/context1.out 2>
/usr/local/bench/archive/2010-06-07_08:53:55/context1.err
stderr looks like this:
**********************************************
Run: "Pipe-based Context Switching": slave write failed: Broken pipe; aborting
Thanks!
Jacob
Original comment by jaco...@gmail.com
on 7 Jun 2010 at 11:41
No, I haven't found a solution in UnixBench or in Python. So, to solve this
issue, I implemented a work around using a java program. Here is the java
source, and what I do is package this java code with UnixBench, and then
compile it during the step where I compile UnixBench, and then simply call this
java program from Python with subprocess.Popen() using a command of java
runbench (my java file name). Just modify the String args command with how you
want to run UnixBench, and this should work, assuming you have a java installed.
runbench.java:
==================================================
import java.io.*;
import java.util.*;
class StreamGobbler extends Thread {
InputStream is;
String type;
StreamGobbler(InputStream is, String type) {
this.is = is;
this.type = type;
}
public void run() {
try {
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line=null;
while((line = br.readLine()) != null)
System.out.println(type + ">" + line);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
public class runbench extends Thread {
static void runbench() {
try {
Runtime runtime = Runtime.getRuntime();
String[] args = new String[] {"bash", "-c", "./Run -c 16"};
Process p = runtime.exec(args);
StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), "ERROR");
StreamGobbler outputGobbler = new StreamGobbler(p.getInputStream(), "OUTPUT");
errorGobbler.start();
outputGobbler.start();
int exitVal = p.waitFor();
System.out.println("ExitValue: " + exitVal);
}
catch (Throwable t) {
t.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
runbench();
}
}
===============================================================
Original comment by kdlu...@gmail.com
on 7 Jun 2010 at 11:50
Original issue reported on code.google.com by
kdlu...@gmail.com
on 3 Nov 2009 at 12:00