|
Am 28.10.2013 18:05 schröbte Rena:assert(posix.dup2(write, 1)) -- replace stdout with pipe-end
#!/usr/bin/env lua5.1
local posix = require('posix')
local function spawn(program, ...)
local read, write = posix.pipe()
local cpid = posix.fork()
if cpid == 0 then --child
HTH,
assert(posix.execp(program, ...))
else return {read=read, write=write, pid=cpid}
end
end
local proc = assert(spawn('ping', '127.0.0.1'))
while true do
local data = "" 1024))
print("ping says:", data)
end
but ping doesn't write to the pipe, and just outputs to my terminal instead.
Philipp