JuliaLang/julia — pull request #8717 by randy3k (2014-10-18 00:55:45+00:00)
Title: process events should be called after flushing

It is discovered [[1]](https://github.com/JuliaLang/IJulia.jl/issues/238) [[2]](https://github.com/JuliaLang/IJulia.jl/pull/240) that `flush_cstdio` doesn't flush stdio immediately. To illustrate it, consider

```
julia> read_stdout, = redirect_stdout()
(Pipe(open, 0 bytes waiting),Pipe(open, 0 bytes waiting))

julia> start_reading(read_stdout);

julia> ccall((:printf, "libc"), Int, (Ptr{Uint8},), "foo");

julia> flush_cstdio(); nb_available(read_stdout)
0
```

```
julia> read_stdout, = redirect_stdout()
(Pipe(open, 0 bytes waiting),Pipe(open, 0 bytes waiting))

julia> start_reading(read_stdout);

julia> ccall((:printf, "libc"), Int, (Ptr{Uint8},), "foo");

julia> flush_cstdio(); Base.process_events(true); nb_available(read_stdout)
3
```

`nb_available` yields a different result if we do `Base.process_events`.