and specifies which ECLiPSe stream should be connected to the stdin, stdout or stderr of the child respectively. Unless null is specified, this will establish pipes to be created between the ECLiPSe process and the child. On Berkeley UNIX systems the streams can be specified as sigio(Stream) which will setup the pipe such that the signal sigio is issued every time new data appears on the pipe. Thus, by defining a suitable interrupt handler, it is possible to service this stream in a completely asynchronous way.[Stdin, Stdout, Stderr]
In this example the child process can be terminated by closing its standard input (in other cases it may be necessary to send a signal). The built-in wait/2 is then used to wait for the process to terminate and to obtain its exit status. Don't forget to close the ECLiPSe streams that were opend by exec/3:[eclipse 1]: exec(bc, [in,out], P). P = 9759 yes. [eclipse 2]: writeln(in, "12345678902321 * 2132"), flush(in). yes. [eclipse 3]: read_string(out, "\n", _, Result). Result = "26320987419748372" yes.
[eclipse 4]: close(in), wait(P,S). P = 9759 S = 0 More? (;) yes. [eclipse 5]: at_eof(out), close(out). yes.