fix(daemon): carry --__daemonized identity marker through exec-restart (#2739) - #2743
Merged
Merged
Conversation
#2739) exec-restart rebuilds the argv from scratch, dropping the --__daemonized marker ForkIntoBackground writes. daemonIdentityMatches keys on that marker (or the ggcode[ argv[0] display name); a restarted daemon's live PID therefore looked like an unrelated process reusing the PID - CheckExistingDaemon deleted the PID file and admitted a SECOND daemon on the next 'ggcode daemon -b'. Fix: append --__daemonized to the rebuilt argv. argv[0] display-name rewriting is deliberately NOT replicated: ExecSelf treats args as the flag list AFTER argv[0], so an injected display name would become a stray positional argument and break cobra parsing; Contains-based identity matching needs the flag alone. The daemonized=true branch the flag selects is behaviorally identical for the restart path (the distinguishing parameter is ignored). Tests: flag-combo parse pin (cmd) + identity match/miss table via the same-package cmdline hook (internal/daemon); both suites green.
Owner
Author
|
合并说明:main_fullstack_agent 平台域复核 approve(双核对实证:daemonIdentityMatches Contains 位置无关+尾部 append 与 FIB 写入语义等价;runDaemon 第 6 参 _ bool 零使用 daemonized=true 行为零差别;设计决策① argv[0] 不复刻合理——ExecSelf args 纯 flag 表 append 成杂散参;darwin/windows 双 vet+探针 2/2;Windows PID 观察非阻塞预先存在)。CI 全绿。执行合并,#2739 随链关闭。 |
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.
Fixes #2739
exec-restart (IM /restart, terminal r) rebuilds the argv from scratch, dropping the
--__daemonizedmarker ForkIntoBackground writes. daemonIdentityMatches keys on that marker (or theggcode[argv[0] display name); a restarted daemon's live PID therefore looked like an unrelated process reusing the PID - CheckExistingDaemon deleted the PID file and admitted a SECOND daemon on the nextggcode daemon -b.Fix: append
--__daemonizedto the rebuilt argv (daemon.go exec-restart path).Design notes:
_ bool).Tests: flag-combo parse pin (cmd/ggcode) + identity match/miss via the same-package cmdline hook (internal/daemon, positive with marker / negative without). Both suites green (22s cmd / 0.2s daemon).