Up | TOC | Index | |||||
<< 7 Included Tools | < 8.7 Operating System Helpers | Up: 8 API Reference | 8.9 Pretty Printing > | 9 Release Notes >> |
8.8 Pipe Input/Output
8.8.1 Notes
Due to a bug, Euphoria does not handle STDERR properly STDERR cannot captured for Euphoria programs (other programs will work fully) The IO functions currently work with file handles, a future version might wrap them in streams so that they can be used directly alongside other file/socket/other-streams with a stream_select() function.
8.8.2 Accessor Constants
8.8.2.1 STDIN
include std/pipeio.e namespace pipeio public enum STDIN
Child processes standard input
8.8.2.2 STDOUT
include std/pipeio.e namespace pipeio public enum STDOUT
Child processes standard output
8.8.2.3 STDERR
include std/pipeio.e namespace pipeio public enum STDERR
Child processes standard error
8.8.2.4 PID
include std/pipeio.e namespace pipeio public enum PID
Process ID
8.8.2.5 PARENT
include std/pipeio.e namespace pipeio public enum PARENT
Set of pipes that are for the use of the parent
8.8.2.6 CHILD
include std/pipeio.e namespace pipeio public enum CHILD
Set of pipes that are given to the child - should not be used by the parent
8.8.3 Opening/Closing
8.8.3.1 process
include std/pipeio.e namespace pipeio public type process(object o)
Process Type
8.8.3.2 close
include std/pipeio.e namespace pipeio public function close(atom fd)
Close handle fd
Returns:
An integer, 0 on success, -1 on failure
Example 1:
integer status = pipeio:close(p[STDIN])
8.8.3.3 kill
include std/pipeio.e namespace pipeio public procedure kill(process p, atom signal = 15)
Close pipes and kill process p with signal signal (default 15)
Comments:
Signal is ignored on Windows.
Example 1:
kill(p)
8.8.4 Read/Write Process
8.8.4.1 read
include std/pipeio.e namespace pipeio public function read(atom fd, integer bytes)
Read bytes bytes from handle fd
Returns:
A sequence, containing data, an empty sequence on EOF or an error code. Similar to get_bytes.
Example 1:
sequence data=read(p[STDOUT],256)
8.8.4.2 write
include std/pipeio.e namespace pipeio public function write(atom fd, sequence str)
Write bytes to handle fd
Returns:
An integer, number of bytes written, or -1 on error
Example 1:
integer bytes_written = write(p[STDIN],"Hello World!")
8.8.4.3 error_no
include std/pipeio.e namespace pipeio public function error_no()
Get error no from last call to a pipe function
Comments:
Value returned will be OS-specific, and is not always set on Windows at least
Example 1:
integer error = error_no()
8.8.4.4 create
include std/pipeio.e namespace pipeio public function create()
Create pipes for inter-process communication
Returns:
A handle, process handles { {parent side pipes},{child side pipes} }
Example 1:
object p = exec("dir", create())
8.8.4.5 exec
include std/pipeio.e namespace pipeio public function exec(sequence cmd, sequence pipe)
Open process with command line cmd
Returns:
A handle, process handles { PID, STDIN, STDOUT, STDERR }
Example 1:
object p = exec("dir", create())