Next: , Previous: , Up: Processes   [Contents][Index]


5.27.4 Process I/O

It is only possible for lisp programs to explicitly send input data to asynchronous processes (by the time it’s possible to call a function to send data to a synchronous process, the process will already have terminated!). Simply use the process object which an asynchronous process is running on as a normal Lisp input stream, any strings or characters written to the stream will immediately be copied to the stdin channel of the subprocess.

With synchronous processes, the only control over input data possible is by giving the call-process function the name of a file containing the subprocess’ input data.

Output data from subprocesses is handled the same way by both asynchronous and synchronous processes: it is simply copied to the stream defined by the output stream component of the subprocess’ process object.

Function: process-output-stream process

Returns the value of the output stream component of the process object process.

Function: set-process-output-stream process stream

Sets the value of the output stream component of the process object process to the stream stream, then returns stream.

By default the stdout and stderr streams are combined, use the set-process-error-stream function to separate them. (Note that this currently only works with pipe connection types.)

Function: process-error-stream process

Returns the value of the error stream component of the process object process.

Function: set-process-error-stream process stream

Sets the value of the error stream component of the process object process to the stream stream, then returns stream.

Output from asynchronous subprocesses (this includes changes of state as well as stream output) is only propagated at well-defined times. Either when in the read stage of the read-eval-print, or input, loop, or when the accept-process-output or sit-for functions are called.

Function: accept-process-output #!optional seconds milliseconds

Wait seconds plus milliseconds for output from any asynchronous subprocesses. If any arrives, process it, then return false. Otherwise return true. If either of the arguments is undefined, they count as zero in the addition.

Function: sit-for #!optional seconds milliseconds

Wait for input to arrive and be processed. No more than seconds seconds plus milliseconds milliseconds will be waited. If at the end of this time no input has arrived, return true. Otherwise return false if input was found.

Note that this function is only distinct to accept-process-output when Librep is embedded in another application, or an extension has been loaded that provides an event loop (such as the gtk binding). In this case other input forms, such as user input, for example, can preempt the timeout.

This function is exported by the rep.system module.

See Streams.


Next: , Previous: , Up: Processes   [Contents][Index]