Skip to content

fix(EINTR): retry operations on interrupt#62

Open
kruton wants to merge 1 commit into
mainfrom
eintr-retry
Open

fix(EINTR): retry operations on interrupt#62
kruton wants to merge 1 commit into
mainfrom
eintr-retry

Conversation

@kruton

@kruton kruton commented Jun 17, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings June 17, 2026 03:00

Copilot AI 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.

Pull request overview

This PR improves robustness of low-level I/O by introducing an EINTR-retry macro and “full read/write” helpers, then applying them to key input/output paths (socket resolver pipe, stdout flush, stdin reads) and tightening a few filesystem-call error paths.

Changes:

  • Add RETRY_ON_EINTR plus read_full / write_full / writev_full helpers to reliably complete syscalls across interrupts and partial I/O.
  • Use the new helpers in nonblocking hostname resolution and in raw output paths (stdout flush, /echo -r).
  • Add error handling for getcwd/getwd usage to avoid propagating NULL/garbage paths.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/port.h Adds RETRY_ON_EINTR macro used to harden syscall loops.
src/util.c Implements read_full, write_full, and writev_full helpers.
src/util.h Exposes the new full I/O helpers to the rest of the codebase.
src/tfio.c Retries stdin read() on EINTR and logs errors.
src/socket.c Uses full read/write helpers for resolver IPC and refactors resolver cleanup.
src/output.c Retries write() in bufflush() to avoid EINTR-related truncation/spins.
src/command.c Makes getcwd/getwd failures explicit and uses write_full for raw echo.
src/signals.c Avoids using an uninitialized initial directory when getcwd/getwd fails.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/socket.c
Comment thread src/signals.c Outdated
Comment thread src/tfio.c Outdated
Comment thread src/util.h

Copilot AI 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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Comment thread src/tfio.c Outdated
Comment thread src/port.h Outdated
Comment thread src/socket.c Outdated
Comment thread src/socket.c

Copilot AI 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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread src/util.c
Comment on lines +125 to +135
while (niov > 0) {
ssize_t result;
size_t written;

RETRY_ON_EINTR(result, writev(fd, iov, niov));
if (result < 0)
return -1;
if (result == 0) {
errno = EIO;
return -1;
}
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.

2 participants