Make improvements

- Expand redbean UNIX module
- Expand redbean documentation
- Ensure Lua copyright is embedded in binary
- Increase the PATH_MAX limit especially on NT
- Use column major sorting for linenoise completions
- Fix some suboptimalities in redbean's new UNIX API
- Figured out right flags for Multics newline in raw mode
This commit is contained in:
Justine Tunney 2022-04-24 09:59:22 -07:00
parent cf3174dc74
commit 2046c0d2ae
305 changed files with 6602 additions and 4221 deletions

View file

@ -32,8 +32,9 @@ local function main()
-- steal client from redbean
fd = GetClientFd()
rc, errno = unix.fork()
-- this function returns twice
pid, errno = unix.fork()
if errno then
SetStatus(400)
SetHeader('Content-Type', 'text/html; charset=utf-8')
@ -44,7 +45,7 @@ local function main()
Write(EncodeBase64(LoadAsset('/redbean.png')))
Write('">\r\n')
Write('redbean unix demo\r\n')
Write(string.format('<span style="color:red">&nbsp;%s</span>\r\n', unix.strerrno(errno)))
Write('<span style="color:red">&nbsp;%s</span>\r\n' % {unix.strerrno(errno)})
Write('</h1>\r\n')
Write([[
<p>
@ -57,11 +58,13 @@ local function main()
return
end
if rc ~= 0 then
-- the parent process gets the pid
if pid ~= 0 then
unix.close(fd)
return
end
-- if pid is zero then we're the child
-- turn into a daemon
unix.umask(0)
unix.setsid()
@ -119,7 +122,7 @@ local function main()
else
st, err = unix.stat(name)
if st then
unix.write(fd, string.format(' (%d bytes)', st:size()))
unix.write(fd, ' (%d bytes)' % {st:size()})
end
end
unix.write(fd, '\r\n')
@ -127,7 +130,7 @@ local function main()
unix.write(fd, '</ul>\r\n')
else
unix.write(fd, '<p>\r\n')
unix.write(fd, string.format('failed: %s\r\n', EscapeHtml(VisualizeControlCodes(unix:strerror(err)))))
unix.write(fd, 'failed: %s\r\n' % {EscapeHtml(VisualizeControlCodes(unix:strerror(err)))})
unix.write(fd, '</p>\r\n')
end