Skip to content

Copy back the remaining time of interrupted waits as the kernel does - #4142

Open
Keno wants to merge 1 commit into
rr-debugger:masterfrom
ChronitonAI:interrupted-wait-remaining-time
Open

Keno wants to merge 1 commit into
rr-debugger:masterfrom
ChronitonAI:interrupted-wait-remaining-time

Conversation

@Keno

@Keno Keno commented Oct 28, 2026

Copy link
Copy Markdown
Member

[Encountered, debugged, test, patch by AI]

When a signal interrupts select(), pselect6 or ppoll, the kernel writes the remaining time to the timeout argument, and a restart waits only for that time. rr gave them scratch memory for it and didn't copy it back then, so their timeouts started over after every signal without a handler, and after EINTR the program found its original timeout. Copy it back at the interruption, as for sleeps.

The kernel doesn't write the remaining time of a TIMER_ABSTIME sleep, so don't give it scratch memory, which rr copied over that argument when a signal interrupted the sleep.

Test: intr_remaining_time.

When a signal interrupts select(), pselect6 or ppoll, the kernel
writes the remaining time to the timeout argument, and a restart
waits only for that time. rr gave them scratch memory for it and
didn't copy it back then, so their timeouts started over after every
signal without a handler, and after EINTR the program found its
original timeout. Copy it back at the interruption, as for sleeps.

The kernel doesn't write the remaining time of a TIMER_ABSTIME sleep,
so don't give it scratch memory, which rr copied over that argument
when a signal interrupted the sleep.

Test: intr_remaining_time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Keno
Keno force-pushed the interrupted-wait-remaining-time branch from dbd40b9 to ff93f50 Compare October 28, 2026 05:11

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant