File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
src/main/java/org/perlonjava/runtime Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ public class RuntimeIO implements RuntimeScalarReference {
64
64
65
65
// State flags
66
66
private boolean isEOF ;
67
- private boolean needFlush ;
67
+ boolean needFlush ;
68
68
69
69
// Constructor to initialize buffers
70
70
public RuntimeIO () {
Original file line number Diff line number Diff line change 25
25
import java .util .concurrent .TimeUnit ;
26
26
27
27
import static org .perlonjava .runtime .GlobalContext .getGlobalVariable ;
28
+ import static org .perlonjava .runtime .RuntimeIO .stderr ;
29
+ import static org .perlonjava .runtime .RuntimeIO .stdout ;
28
30
import static org .perlonjava .runtime .RuntimeScalarCache .*;
29
31
30
32
/**
@@ -1560,6 +1562,15 @@ public RuntimeScalar hex() {
1560
1562
}
1561
1563
1562
1564
public RuntimeScalar sleep () {
1565
+
1566
+ // Flush stdout and stderr before reading, in case we are displaying a prompt
1567
+ if (stdout .needFlush ) {
1568
+ stdout .flush ();
1569
+ }
1570
+ if (stderr .needFlush ) {
1571
+ stderr .flush ();
1572
+ }
1573
+
1563
1574
long s = (long ) this .getDouble () * 1000 ;
1564
1575
try {
1565
1576
TimeUnit .MILLISECONDS .sleep (s );
You can’t perform that action at this time.
0 commit comments