Add more apis to redbean unix module

- Document unix.fcntl()
- Add POSIX Advisory Locks
- Add mask parameter to unix.poll()
- Add lowest parameter to unix.dup()
This commit is contained in:
Justine Tunney 2022-08-16 23:23:34 -07:00
parent ce588dd56b
commit a1aaf23dc1
16 changed files with 432 additions and 102 deletions

View file

@ -507,21 +507,11 @@
#define MAKE_HOST "x86_64-cosmopolitan"
/* Define to 1 to enable job server support in GNU make. */
/*
* TODO(jart): Why does job server not work? We don't need it, since the
* last thing we'd ever want is a recursive make, however it
* would be nice to confirm it's not a bug in our libc impl.
*/
/* #define MAKE_JOBSERVER 1 */
#define MAKE_JOBSERVER 1
/* Define to 1 to enable symbolic link timestamp checking. */
#define MAKE_SYMLINKS 1
/* Use GNU style printf and scanf. */
#ifndef __USE_MINGW_ANSI_STDIO
#define __USE_MINGW_ANSI_STDIO 1
#endif
/* Define to 1 if the nlist n_name member is a pointer */
/* #undef N_NAME_POINTER */

View file

@ -16,6 +16,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "third_party/make/makeint.inc"
/**/
#include "libc/sock/select.h"
#include "libc/sysv/consts/f.h"
#include "libc/sysv/consts/fd.h"
#include "libc/sysv/consts/sa.h"
@ -231,18 +232,16 @@ unsigned int jobserver_acquire(int timeout) {
FD_SET(job_fds[0], &readfds);
r = pselect(job_fds[0] + 1, &readfds, NULL, NULL, specp, &empty);
if (r < 0) switch (errno) {
case EINTR:
if (r < 0)
{
if (errno == EINTR)
/* SIGCHLD will show up as an EINTR. */
return 0;
case EBADF:
if (errno == EBADF)
/* Someone closed the jobs pipe.
That shouldn't happen but if it does we're done. */
O(fatal, NILF, _("job server shut down"));
default:
pfatal_with_name(_("pselect jobs pipe"));
pfatal_with_name(_("pselect jobs pipe"));
}
if (r == 0) /* Timeout. */