Commit ced9e8c
fix: resolve daemon startup race conditions (#45)
Three race conditions were causing the daemon to silently fail during
startup, leaving the battery charging uncontrolled:
- launchd bootout followed immediately by bootstrap returns I/O error
because launchd hasn't finished cleanup. Added 0.5s delay between
the two calls and retry-on-failure for bootstrap.
- createSafetyDaemon() kickstarted the safety watchdog before the main
daemon was running, causing the watchdog to detect a missing daemon
and attempt a conflicting restart. Removed the kickstart -- the
watchdog now relies on StartCalendarInterval (:00/:30).
- Maintain sent SIGTERM to the old daemon and immediately proceeded
with startup. The old daemon's cleanup (re-enable charging, exit)
could race with the new daemon's bootout. Now waits up to 5s for
the old process to exit.
Bumps version to 2.1.2.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 05dfc12 commit ced9e8c
3 files changed
Lines changed: 21 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
103 | 108 | | |
104 | 109 | | |
105 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | 80 | | |
82 | | - | |
83 | | - | |
| 81 | + | |
84 | 82 | | |
85 | | - | |
86 | 83 | | |
87 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
88 | 89 | | |
89 | | - | |
90 | | - | |
91 | 90 | | |
92 | 91 | | |
93 | 92 | | |
| |||
166 | 165 | | |
167 | 166 | | |
168 | 167 | | |
169 | | - | |
170 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
171 | 177 | | |
172 | 178 | | |
173 | 179 | | |
| |||
0 commit comments