Skip to content

feat(signals): honored SA_RESTART for interrupted syscalls - #168

Merged
FlareCoding merged 1 commit into
masterfrom
pr/syscall-restart
Aug 13, 2026
Merged

feat(signals): honored SA_RESTART for interrupted syscalls#168
FlareCoding merged 1 commit into
masterfrom
pr/syscall-restart

Conversation

@FlareCoding

Copy link
Copy Markdown
Owner

Summary

  • Handlers installed through musl's signal() set SA_RESTART, but interrupted blocking calls always surfaced EINTR, breaking ported programs that never expect it.
  • Restartable waits (read/write, sockets, futex, proc_wait) return an internal ERESTARTSYS that the delivery boundary rewinds for re-execution under SA_RESTART, converts to EINTR otherwise, or restarts transparently when no handler ran; poll/select and nanosleep keep EINTR, matching Linux.
  • Handled signals no longer interrupt or wake elevated tasks, which cannot run a handler, closing a restart livelock and spurious poll/futex results.

Made with Cursor

Handlers installed through musl's signal() set SA_RESTART, so every
interrupted blocking call surfaced a spurious EINTR. Restartable waits
now return an internal ERESTARTSYS the delivery boundary rewinds for
re-execution or converts to EINTR, and handled signals no longer wake
elevated tasks that cannot deliver them.

Co-authored-by: Cursor <cursoragent@cursor.com>
@FlareCoding
FlareCoding merged commit a3ef809 into master Aug 13, 2026
15 checks passed
@FlareCoding
FlareCoding deleted the pr/syscall-restart branch August 13, 2026 04:43

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit a9381c4. Configure here.

case resource::ERR_NOENT: return syscall::ENOENT;
case resource::ERR_NOTDIR: return syscall::ENOTDIR;
case resource::ERR_INTR: return syscall::EINTR;
case resource::ERR_INTR: return syscall::ERESTARTSYS;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Connect restart fails after signal

High Severity · Logic Bug

Mapping socket ERR_INTR to ERESTARTSYS makes blocking connect restartable under SA_RESTART, but tcp_connect only accepts CLOSED sockets. An interrupt during the SYN_SENT wait leaves the socket in SYN_SENT, so the restarted call returns EINVAL instead of finishing the handshake. With musl signal() (which sets SA_RESTART), a signal during connect turns a normal interrupt into a hard failure.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a9381c4. Configure here.

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