From this answer on the Time Unix command I get the basic idea on how time works. It forks a new process and execute the command in that new process. However, I have encountered a behavior that I am not able to understand.
I am trying to profile lusearch, a benchmark of the DaCapo benchmark suite. I want to launch it with different configurations (number of threads and number of iterations), disregard the benchmark output and use time to record real, user and system time. With the vast majority of the configurations, my script works just fine, launches the benchmark and records the time.
With one particular configuration (large dataset, two threads and ten iterations) the benchmark sometimes does not reach termination (80% of the cases, out of almost 100 tentatives). This is the command I am using to launch it:
(time -p java -jar DaCapo.jar lusearch -s large -t 2 -i 10
>/dev/null 2>/dev/null) 2>&1 | awk '{print $2 $4 $6}' > timed &
However, if I don't prepend time the benchmark just terminates 100% of the times (in about 100 tentatives as well):
(java -jar DaCapo.jar lusearch -s large -t 2 -i 10 >/dev/null 2>/dev/null)
This behavior happens only with this benchmark - and with this configuration -, while if profile some other benchmark or use a different number number of threads or a different number of iterations I don't see the same thing happening. My guess would be that it has to do with something that time is doing that interferes with the benchmark.
I don't see how a fork+exec could change the benchmark behavior. Is there anything specific that can cause this? For example: is time using some resource that the benchmark wants to use as well? I am doing something wrong while launching the benchmark?