Skip to content

Handle _io3 syscall return states#64

Open
salva wants to merge 1 commit into
masterfrom
fix/io3-syscall-return-handling
Open

Handle _io3 syscall return states#64
salva wants to merge 1 commit into
masterfrom
fix/io3-syscall-return-handling

Conversation

@salva

@salva salva commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Summary

Make _io3 distinguish zero-byte successful returns from errno-bearing syscall failures.

Changes

  • Treat sysread returning 0 as EOF without consulting stale $!.
  • Consult $! for sysread only when the return value is undef.
  • Consult $! for syswrite only when the return value is undef.

Fixes #39.
Fixes #40.

Testing

  • perl -Ilib -c lib/Net/OpenSSH.pm
  • perl -Ilib t/1_run.t

Copilot AI review requested due to automatic review settings June 4, 2026 11:56

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 updates the internal _io3 I/O loop in Net::OpenSSH to correctly distinguish EOF/zero-byte successful returns from errno-bearing syscall failures, avoiding retries driven by stale $!.

Changes:

  • Treat sysread(...) == 0 as EOF (close/disable the relevant output handle) without consulting $!.
  • Consult $! for sysread only when the return value is undef (error case).
  • Consult $! for syswrite only when the return value is undef (error case).

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

Comment thread lib/Net/OpenSSH.pm
$read and $debug & 128 and _hexdump substr $bout, $offset;
}
unless ($read or grep $! == $_, @retriable) {
unless (defined($read) ? $read : grep $! == $_, @retriable) {
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.

_io3 checks stale errno after zero-byte syswrite _io3 checks stale errno after sysread returns EOF

2 participants