-- pipe.lua
-- $Id: pipe.lua,v 1.3 2004/11/16 23:43:14 cpressey Exp $
-- Test of the libaura pipe binding.

p = Pipe.open("ls -la")

line, err = p:readline()
while line do
	print(line)
	line, err = p:readline()
end

reason = "UNKNOWN?!?"
if (err == Pipe.EOF) then reason = "end of file" end
if (err == Pipe.TIMEOUT) then reason = "timeout" end
if (err == Pipe.SELECT_ERR) then reason = "error from select()" end
if (err == Pipe.FGETS_ERR) then reason = "error from fgets()" end

print("Stopped, reason: " .. reason)

pstat = p:close()

print("Status from p:close()=" .. pstat)

