Add more documentation to redbean

This change also improves the unix module, adding a reboot() system call
for fun and profit, fixing the execve() api, and a printimage release.
This commit is contained in:
Justine Tunney 2022-04-21 04:01:42 -07:00
parent 87396f43bc
commit 9bfa6ec06e
16 changed files with 498 additions and 133 deletions

26
tool/net/demo/unix2.lua Normal file
View file

@ -0,0 +1,26 @@
-- example of how to run the ls command
-- and pipe its output to the http user
local unix = require "unix"
ls = unix.commandv("ls")
reader, writer = unix.pipe()
if unix.fork() == 0 then
unix.close(1)
unix.dup(writer)
unix.close(writer)
unix.close(reader)
unix.execve(ls, {ls, "-Shal"})
unix.exit(127)
else
unix.close(writer)
SetHeader('Content-Type', 'text/plain')
while true do
data = unix.read(reader)
if data ~= "" then
Write(data)
else
break
end
end
unix.close(reader)
unix.wait(-1)
end