Skip to content

Commit 514dfc9

Browse files
danielbodartclaude
andcommitted
Wait for old service teardown before bootstrap in macOS update script
bootout is async — launchctl may not have fully deregistered the old service by the time bootstrap runs, causing "Input/output error" (5). Poll until the service is gone (up to 10s) before bootstrapping. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0dfd3da commit 514dfc9

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

dist/macos/capsper-update.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ main() {
169169
local plist_path="$HOME/Library/LaunchAgents/$PLIST_LABEL.plist"
170170
if [ -f "$plist_path" ]; then
171171
echo "Restarting service..."
172+
# bootout is async — wait for the old service to fully tear down
173+
local attempts=0
174+
while launchctl print "gui/$(id -u)/$PLIST_LABEL" >/dev/null 2>&1; do
175+
sleep 1
176+
attempts=$((attempts + 1))
177+
if [ "$attempts" -ge 10 ]; then
178+
echo "Warning: old service still registered after ${attempts}s"
179+
break
180+
fi
181+
done
172182
launchctl bootstrap "gui/$(id -u)" "$plist_path"
173183
echo "Service restarted. Check logs with:"
174184
echo " tail -f $INSTALL_DIR/capsper.log"

0 commit comments

Comments
 (0)