Skip to content

fix(sysseek): return new file position instead of success flag#528

Merged
fglock merged 1 commit intomasterfrom
fix/sysseek-return-position
Apr 21, 2026
Merged

fix(sysseek): return new file position instead of success flag#528
fglock merged 1 commit intomasterfrom
fix/sysseek-return-position

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 21, 2026

Summary

Fixes jcpan -t File::Tail, which hung forever during its test suite.

Root cause

sysseek was aliased to seek, which returns 1 on success. Perl's sysseek is documented to return the new file position (with the special "0 but true" dualvar for position 0).

File::Tail::checkpending uses sysseek($fh, 0, SEEK_END) to detect new data at the tail of the file. With the old behavior endpos always came back as 1, so endpos - curpos == 0 and the polling loop in File::Tail::read never made progress.

Minimal repro (before fix):

open(W,">/tmp/f"); print W "hello\n"; close W;
open(RD,"<$name");
print sysseek(RD,0,2);   # printed "1", expected "6"

Fix

  • Added a proper sysseek(RuntimeScalar, RuntimeList) in IOOperator that performs the seek, then returns the new position via tell, mapping position 0 to the "0 but true" string.
  • Rewired OperatorHandler so sysseek dispatches to the new method instead of reusing seek.
  • Updated the (int ctx, RuntimeBase...) adapter used by MiscOpcodeHandler accordingly.

Test plan

  • ./jperl round-trip of sysseek with all whence values returns correct positions (including "0 but true" for position 0).
  • jcpan -t File::Tail now reports Files=3, Tests=15, Result: PASS.
  • make (full unit test suite) passes.

Generated with Devin

sysseek was aliased to seek, which returns 1 on success. Perl's
sysseek is documented to return the new position (with "0 but true"
for position 0). File::Tail relies on sysseek($fh, 0, SEEK_END) to
detect new data; with the old behavior it always saw endpos=1 and
its polling loop hung forever.

Gave sysseek its own implementation in IOOperator (seek + tell,
mapping position 0 to "0 but true") and updated OperatorHandler to
dispatch "sysseek" to the new method.

Verified with jcpan -t File::Tail (Files=3, Tests=15, Result: PASS).

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock merged commit 9a275c7 into master Apr 21, 2026
2 checks passed
@fglock fglock deleted the fix/sysseek-return-position branch April 21, 2026 17:39
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