mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Make improvements
- Add GetCpuCount() API to redbean - Add unix.gmtime() API to redbean - Add unix.readlink() API to redbean - Add unix.localtime() API to redbean - Perfect the new redbean UNIX module APIs - Integrate with Linux clock_gettime() vDSO - Run Lua garbage collector when malloc() fails - Fix another regression quirk with linenoise repl - Fix GetProgramExecutableName() for systemwide installs - Fix a build flake with test/libc/mem/test.mk SRCS list
This commit is contained in:
parent
860ea18a87
commit
d57b81aac7
51 changed files with 3096 additions and 1395 deletions
|
@ -1,4 +1,4 @@
|
|||
local unix = require "unix"
|
||||
local unix = require 'unix'
|
||||
|
||||
local function main()
|
||||
if GetMethod() ~= 'GET' and GetMethod() ~= 'HEAD' then
|
||||
|
@ -45,7 +45,7 @@ local function main()
|
|||
Write(EncodeBase64(LoadAsset('/redbean.png')))
|
||||
Write('">\r\n')
|
||||
Write('redbean unix demo\r\n')
|
||||
Write('<span style="color:red"> %s</span>\r\n' % {unix.strerrno(errno)})
|
||||
Write('<span style="color:red"> %s</span>\r\n' % {EscapeHtml(tostring(errno))})
|
||||
Write('</h1>\r\n')
|
||||
Write([[
|
||||
<p>
|
||||
|
@ -63,7 +63,6 @@ local function main()
|
|||
unix.close(fd)
|
||||
return
|
||||
end
|
||||
|
||||
-- if pid is zero then we're the child
|
||||
-- turn into a daemon
|
||||
unix.umask(0)
|
||||
|
@ -106,34 +105,6 @@ local function main()
|
|||
unix.write(fd, 'became an autonomous daemon reparented on your init!\r\n')
|
||||
unix.write(fd, '</p>\r\n')
|
||||
|
||||
unix.write(fd, '<h2>listing of current directory</h2>\r\n')
|
||||
dir, err = unix.opendir('.')
|
||||
if dir then
|
||||
unix.write(fd, '<ul>\r\n')
|
||||
while true do
|
||||
name, errno, kind, ino, off = dir:read()
|
||||
if not name then
|
||||
break
|
||||
end
|
||||
unix.write(fd, '<li>')
|
||||
unix.write(fd, EscapeHtml(VisualizeControlCodes(name)))
|
||||
if kind == unix.DT_DIR then
|
||||
unix.write(fd, '/')
|
||||
else
|
||||
st, err = unix.stat(name)
|
||||
if st then
|
||||
unix.write(fd, ' (%d bytes)' % {st:size()})
|
||||
end
|
||||
end
|
||||
unix.write(fd, '\r\n')
|
||||
end
|
||||
unix.write(fd, '</ul>\r\n')
|
||||
else
|
||||
unix.write(fd, '<p>\r\n')
|
||||
unix.write(fd, 'failed: %s\r\n' % {EscapeHtml(VisualizeControlCodes(unix:strerror(err)))})
|
||||
unix.write(fd, '</p>\r\n')
|
||||
end
|
||||
|
||||
-- terminate
|
||||
unix.close(fd)
|
||||
unix.exit(0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue