fix(gateway): prevent service process from detecting itself as duplicate#70
Merged
drpedapati merged 1 commit intomainfrom Feb 23, 2026
Merged
fix(gateway): prevent service process from detecting itself as duplicate#70drpedapati merged 1 commit intomainfrom
drpedapati merged 1 commit intomainfrom
Conversation
The foreground guard (dec0eee) checks launchctl print to prevent double-running when the managed service is active. However, when launchd spawns the gateway, launchctl print shows the live PID of *that very process*, causing it to immediately exit with "Gateway is already running" — producing a crash loop. Two fixes: 1. Skip the foreground guard when XPC_SERVICE_NAME (launchd) or INVOCATION_ID (systemd) env vars are set, indicating the process IS the managed service. 2. Use hasNonZeroPID() in Status() instead of checking for any "pid =" substring — "pid = 0" appears when the service is bootstrapped but not actually running, causing false positives. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
XPC_SERVICE_NAME(launchd) orINVOCATION_ID(systemd) env vars are set, so the managed service process doesn't detect itself as a duplicate and crash-loophasNonZeroPID()inStatus()instead of checking for anypid =substring —pid = 0appears when the service is bootstrapped but not running, causing false positivesTest plan
sciclaw service statusshows Running=yesmake buildcompiles cleanlysciclaw service install && sciclaw service start— no crash loop🤖 Generated with Claude Code