Improve threading support further

This commit is contained in:
Justine Tunney 2022-05-17 04:14:28 -07:00
parent 8bfb70ca3f
commit ce71677156
61 changed files with 882 additions and 747 deletions

View file

@ -20,6 +20,8 @@
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/calls/strace.internal.h"
#include "libc/intrin/kprintf.h"
#include "libc/intrin/spinlock.h"
#include "libc/macros.internal.h"
#include "libc/sock/internal.h"
#include "libc/sysv/errfuns.h"
@ -46,6 +48,7 @@
*/
int close(int fd) {
int rc;
_spinlock(&__fds_lock);
if (fd == -1) {
rc = 0;
} else if (fd < 0) {
@ -74,9 +77,10 @@ int close(int fd) {
}
}
if (!__vforked) {
__releasefd(fd);
__releasefd_unlocked(fd);
}
}
_spunlock(&__fds_lock);
STRACE("%s(%d) → %d% m", "close", fd, rc);
return rc;
}