liboleg-2010.1.2: A collection of Oleg Kiselyov's Haskell modules (2008-2010)

System.SysOpen

Description

http://okmij.org/ftp/Haskell/misc.html#sys_open

Haskell interface to sys_open.c: providing openFd and closeFd that can deal with extended file names (which can name TCP and bi-directional pipes in addition to the regular disk files) http://okmij.org/ftp/syscall-interpose.html#Application

Also included a useful utility read_line to read a NL-terminated line from an Fd. It deliberately uses no handles and so never messes with Fd (in particular, it doesn't put the file descriptor in the non-blocking mode)

Simple and reliable uni- and bi-directional pipes

MySysOpen module offers a reliable, proven way of interacting with another local or remote process via a unidirectional or bidirectional channel. It supports pipes and Unix and TCP sockets. MySysOpen is a simple and explicit alternative to the multi-threaded IO processing of the GHC run-time system. The module is the Haskell binding to sys_open -- the extended, user-level file opening interface.

The second half of MySysOpen.hs contains several bi-directional channel interaction tests. One checks repeated sending and receiving of data; the amount of received data is intentionally large, about 510K. Two other tests interact with programs that are not specifically written for interactive use, such as sort. The latter cannot produce any output before it has read all of the input, accepting no input terminator other than the EOF condition. One test uses shutdown to set the EOF condition. The other test programs the handler for a custom EOF indicator, literally in the file name of the communication pipe.

Synopsis

Documentation

mysysCloseOut :: Fd -> IO ()Source

Close the output direction of the bi-directional pipe

read_line :: [Char] -> Fd -> IO ([Char], [Char])Source