mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48:31 +00:00
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:
parent
87396f43bc
commit
9bfa6ec06e
16 changed files with 498 additions and 133 deletions
26
tool/net/demo/unix2.lua
Normal file
26
tool/net/demo/unix2.lua
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue