fix: skip shell fork when temperature tools unavailable (#8)#22
Merged
Conversation
aebd833 to
40aa50f
Compare
- 3-state TemperatureToolState enum: .unchecked / .unavailable / .resolved(kind:, path:) - resolveTemperatureTool() now echoes both tool kind and resolved path via command -v - runTemperatureCommand takes resolved path directly — no more hardcoded /usr/local/bin - detection and execution share the same source-of-truth resolved path - 3-state caching behavior preserved: unresolved = detects once, unavailable = skips detection
40aa50f to
fae91bb
Compare
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.
改动说明
SystemMetricsProvider.bestEffortCPUTemperature在 Apple Silicon 温度读取失败后 fallback 到 shell 命令时,每次 cache 失效都会 fork/exec 一个 zsh + 两条command -v检测,工具不存在时 exit 127,白跑进程。解决方案
availableCommandCache: String?缓存已确认可用的命令路径istats和osx-cpu-temp,确认后再执行实际命令nil,并将 cache 设为nil;后续调用跳过检测直接返回关键语义
availableCommandCache == nil(初始态):尚未检测,需要检测availableCommandCache == ""(检测后):两个工具都找不到,后续跳过availableCommandCache == "/path/to/istats"(检测后):找到可用的,后续直接用行为变化
Closes #8