0 | module System.Posix.Pipe.Prim
 1 |
 2 | import public System.Posix.File.Prim
 3 |
 4 | %default total
 5 |
 6 | --------------------------------------------------------------------------------
 7 | -- FFI
 8 | --------------------------------------------------------------------------------
 9 |
10 | %foreign "C:li_pipe, posix-idris"
11 | prim__pipe : AnyPtr -> PrimIO CInt
12 |
13 | %foreign "C:li_mkfifo, posix-idris"
14 | prim__mkfifo : String -> ModeT -> PrimIO CInt
15 |
16 | --------------------------------------------------------------------------------
17 | -- API
18 | --------------------------------------------------------------------------------
19 |
20 | ||| Creates a pipe and writes the two file descriptors into the given C-array,
21 | ||| the read end at position 0 the write end at position 1.
22 | export %inline
23 | pipe : CArrayIO 2 Fd -> EPrim ()
24 | pipe p = toUnit $ prim__pipe (unsafeUnwrap p)
25 |
26 | ||| Creates a new FIFO (named pipe) on disc.
27 | export %inline
28 | mkfifo : String -> ModeT -> EPrim ()
29 | mkfifo pth m = toUnit $ prim__mkfifo pth m
30 |