I’m using SWI-Prolog version 8.1.6
Is it possible to connect an already-open stream to the input/output/error of a process using
process_create/3? I see the
stdout arguments, but they only give “fresh” pipes.
i.e., is there some way to do something like
test(Status) :- setup_call_cleanup( ( open("foo_out", write, Out), open("foo_in", read, In), open("foo_err", write, Err) ), ( process_create(path(cat), , [ process(Pid), % below gives % error: `process_stream' expected, found <stream>(...) % if I try stdout(pipe(Out)), then it's "Uninstantiated argument expected" stdin(In), stdout(Out), stderr(Err) ]), process_wait(Pid, Status) ), ( close(Out), close(In), close(Err) ) ).
and have the files
foo_err used as the output, input, and error of some process?
Failing this working directly, is there some simple way to just connect the streams returned by giving
stdout(pipe(NewOut)) to the stream I’ve opened?