Merge branch 'alarm_fix' into 'master'

Alarm fix

See merge request redox-os/relibc!1349
This commit is contained in:
Jeremy Soller
2026-05-18 16:52:05 -06:00
2 changed files with 54 additions and 2 deletions
+3 -2
View File
@@ -1232,10 +1232,11 @@ impl Pal for Sys {
}
let path = format!("/scheme/time/{clock_id}");
let timerfd = FdGuard::open(&path, syscall::O_RDWR)?;
let timerfd = FdGuard::open(&path, syscall::O_RDWR)?.to_upper()?;
let eventfd = FdGuard::new(Error::demux(unsafe {
event::redox_event_queue_create_v1(0)
})?);
})?)
.to_upper()?;
let caller_thread = Self::current_os_tid();
let timer_buf = unsafe {
+51
View File
@@ -0,0 +1,51 @@
#include <errno.h>
#include <err.h>
#include <poll.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../test_helpers.h"
#include "signals_list.h"
static void handler(int signum)
{
(void) signum;
int errnum = errno;
printf("SIGUSR1\n");
fflush(stdout);
errno = errnum;
}
int main(void)
{
signal(SIGUSR1, handler);
sigset_t sigusr1;
sigemptyset(&sigusr1);
sigaddset(&sigusr1, SIGUSR1);
sigprocmask(SIG_BLOCK, &sigusr1, NULL);
sigset_t empty;
sigemptyset(&empty);
int fds[2];
if ( pipe(fds) )
err(1, "pipe");
close(fds[0]);
alarm(1);
struct pollfd pfd = { .fd = fds[0], .events = POLLIN };
// POSIX requires EINTR or returning the pending events.
int ret = ppoll(&pfd, 1, NULL, &empty);
if ( ret < 0 )
ERROR_IF(ppoll, ret, <0);
if ( pfd.revents & POLLIN )
ERROR_IF(ppoll, pfd.revents, & POLLIN);
if ( pfd.revents & POLLOUT )
ERROR_IF(ppoll, pfd.revents, & POLLOUT);
if ( pfd.revents & POLLERR )
ERROR_IF(ppoll, pfd.revents, & POLLERR);
if ( pfd.revents & POLLHUP )
ERROR_IF(ppoll, pfd.revents, & POLLHUP);
if ( pfd.revents & POLLNVAL ){
return EXIT_SUCCESS;
}
return 0;
}