Fix stat mtime read on GNU/Linux (SessionStart hook crashes during compact) - #49
Open
Shibachan1015 wants to merge 1 commit into
Open
Fix stat mtime read on GNU/Linux (SessionStart hook crashes during compact)#49Shibachan1015 wants to merge 1 commit into
Shibachan1015 wants to merge 1 commit into
Conversation
…act)
`stat -f %m FILE` is BSD/macOS syntax. On GNU/Linux, `-f` means
`--file-system`, so the command fails on the bogus `%m` argument and
prints filesystem info to *stdout*. Because only stderr is redirected
(`2>/dev/null`), that output leaks into CONFIG_MTIME / METH_MTIME, and
the following arithmetic aborts:
session-orient.sh: line 146: File: "ops/config.yaml"
This fires on every SessionStart:compact, so Linux users crash the hook
whenever a session compacts.
Fix: try the GNU form (`stat -c %Y`) first and fall back to BSD
(`stat -f %m`). Works on both Linux and macOS. Applied to all three
files using the pattern.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XvXshgWoaTKx7jAFNeyv77
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
stat -f %m FILEis BSD/macOS syntax. On GNU/Linux,-fmeans--file-system, so the command:%margument (exit 1), andFile: "ops/config.yaml" ...).Since only stderr is redirected (
2>/dev/null), that stdout leaks intoCONFIG_MTIME/METH_MTIME. The subsequent arithmetic then aborts:This runs on every
SessionStart:compact, so Linux users hit a hook crash whenever a session compacts.Reproduce (Linux)
Fix
Try the GNU form (
stat -c %Y) first, fall back to BSD (stat -f %m). Works on both Linux and macOS. Applied to all three files using the pattern:hooks/scripts/session-orient.sh(lines 142, 145)skill-sources/rethink/SKILL.mdskills/health/SKILL.mdVerified on GNU/Linux:
CONFIG_MTIMEnow resolves to a clean epoch integer and the arithmetic runs without error.🤖 Generated with Claude Code
https://claude.ai/code/session_01XvXshgWoaTKx7jAFNeyv77