FIFOStream(path::String=_mktemp(); read=false, write=!read, cleanup=true)
  -> UnixFIFOStream (on Unix) / FallbackFIFOStream (on non-Unix)

An abstract type for either writing to, or reading from external commands through Unix pipes or temporary files. All subtypes T<:FIFOStream implement the following interface:

  1. Create stream s, optionally from specific path: s = T([path::String]; opts...)
  2. Attach an external command that reads from / writes to that path: attach(s, `foo $(path(s))`[, stdios...])
  3. Write to / read from the stream, just like any other IO object
  4. Close the stream with close(s; rm=s.cleanup)


julia> s = FIFOStream();

julia> io = IOBuffer();

julia> attach(s, pipeline(`cat $(path(s))`, stdout=io));

julia> print(s, "Hello, World!")

julia> close(s)

julia> Text(String(take!(io)))
Hello, World!

julia> s = FIFOStream(read=true);

julia> attach(s, `bash -c "echo 'Hello, World!' > $(path(s))"`);

julia> read(s, String)
"Hello, World!\n"

julia> close(s)
FIFOStreamCollection([T::Type{<:FIFOStream}, ]n::Integer; opts...)

A collection of multiple FIFOStreams, for dealing with multiple streams conveniently.


julia> s = FIFOStreamCollection(2);

julia> io = IOBuffer();

julia> attach(s, pipeline(ignorestatus(`diff --side-by-side $(path(s, 1)) $(path(s, 2))`); stdout=io));

julia> s1, s2 = s;

julia> show(s1, code_lowered(cos, Tuple{Float64}))

julia> show(s2, code_lowered(sin, Tuple{Float64}))

julia> close(s)

julia> # Text(String(take!(io))) # uncomment to show diff