FULL PRODUCT VERSION :
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux mushroom 2.6.18-274.el5 #1 SMP Fri Jul 8 17:36:59 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
If exec is used to run a bash script that in turn runs something else in the background, the stdout/stderr from that command does not reliably make it back to the caller of exec.
Removing the & to not run the command in the background makes it work.
This shows up in Java 7 and 8, but worked in 6. The problem is with both stdout and stderr.
REGRESSION. Last worked in version 6u43
ADDITIONAL REGRESSION INFORMATION:
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run attached program against the echo_cmd.sh script. Data from script does not rerurn reliably.
Remove & from script. Functions as expected.
This works in Java 6 but fails on 7 and 8 (linux). Fails for both stdout and stderr.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
0: Out =
0: Err =
Hello0
Hello1
Hello2
Hello3
Hello4
Hello5
Hello6
Hello7
Hello8
Hello9
1: Out =
1: Err =
Hello0
Hello1
Hello2
Hello3
Hello4
Hello5
Hello6
Hello7
Hello8
Hello9
2: Out =
2: Err =
Hello0
Hello1
Hello2
Hello3
Hello4
Hello5
Hello6
Hello7
Hello8
Hello9
3: Out =
3: Err =
Hello0
Hello1
Hello2
Hello3
Hello4
Hello5
Hello6
Hello7
Hello8
Hello9
4: Out =
4: Err =
Hello0
Hello1
Hello2
Hello3
Hello4
Hello5
Hello6
Hello7
Hello8
Hello9
5: Out =
5: Err =
Hello0
Hello1
Hello2
Hello3
Hello4
Hello5
Hello6
Hello7
Hello8
Hello9
6: Out =
6: Err =
Hello0
Hello1
Hello2
Hello3
Hello4
Hello5
Hello6
Hello7
Hello8
Hello9
7: Out =
7: Err =
Hello0
Hello1
Hello2
Hello3
Hello4
Hello5
Hello6
Hello7
Hello8
Hello9
8: Out =
8: Err =
Hello0
Hello1
Hello2
Hello3
Hello4
Hello5
Hello6
Hello7
Hello8
Hello9
9: Out =
9: Err =
Hello0
Hello1
Hello2
Hello3
Hello4
Hello5
Hello6
Hello7
Hello8
Hello9
ACTUAL -
0: Out =
0: Err =
1: Out =
1: Err =
2: Out =
2: Err =
3: Out =
3: Err =
4: Out =
4: Err =
5: Out =
5: Err =
6: Out =
6: Err =
7: Out =
7: Err =
8: Out =
8: Err =
9: Out =
9: Err =
REPRODUCIBILITY :
This bug can be reproduced always.
I've attached the sources to the bug report. Download all three files to local directory and run. (I can't reproduce on solaris) - Seen on linux.
CUSTOMER SUBMITTED WORKAROUND :
Cannot use bash backgrounding in this situation.