LibC: Implement pthread cancelation

This code is not tested at all but it looks correct xD
This commit is contained in:
2025-06-01 00:59:22 +03:00
parent 56fdf6002c
commit dbdefa0f4a
15 changed files with 165 additions and 16 deletions

View File

@@ -1,9 +1,11 @@
#include <poll.h>
#include <pthread.h>
#include <sys/syscall.h>
#include <unistd.h>
int poll(struct pollfd fds[], nfds_t nfds, int timeout)
{
pthread_testcancel();
if (timeout < 0)
return ppoll(fds, nfds, nullptr, nullptr);
const timespec timeout_ts {
@@ -15,5 +17,6 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout)
int ppoll(struct pollfd fds[], nfds_t nfds, const struct timespec* timeout, const sigset_t* sigmask)
{
pthread_testcancel();
return syscall(SYS_PPOLL, fds, nfds, timeout, sigmask);
}