Skip to content

Don't raise SIGPIPE when sending on a defunct NTP socket - #6

Merged
ps2 merged 1 commit into
masterfrom
no-sigpipe
Nov 21, 2026
Merged

ps2 merged 1 commit into
masterfrom
no-sigpipe

Conversation

@ps2

@ps2 ps2 commented Nov 20, 2026

Copy link
Copy Markdown

iOS defuncts the sockets of a suspended app. NTPConnection creates its UDP CFSocket on its lock queue but sends from the socket's write callback on the main run loop. If the app is suspended between the two, the send after the resume hits a defunct socket, and CFSocketSendData fails with EPIPE. The socket doesn't set SO_NOSIGPIPE, so the kernel also raises SIGPIPE, which kills the host app.

Loop was killed this way twice in one morning. Both times launchd logged exited due to SIGPIPE | sent by Loop, seconds after a background resume, and left no crash report. The relaunch after the second death was then suspended before the CGM manager started, so Loop missed CGM readings until it was opened.

This sets SO_NOSIGPIPE on the socket right after it's created. A send on a defunct socket now just returns an error, and the existing complete(.failure) path retries with a new socket.

iOS defuncts the sockets of a suspended app. If a query's socket was
opened before a suspension and its write callback runs after the
resume, CFSocketSendData fails with EPIPE, and without SO_NOSIGPIPE the
kernel kills the host app. Loop was killed this way twice in one
morning, seconds after background resumes. With the flag the send
returns an error, which the existing failure path already handles.
@ps2
ps2 merged commit 1b4d51e into master Nov 21, 2026
ps2 added a commit to LoopKit/LoopWorkspace that referenced this pull request Nov 21, 2026
A write to a socket the server had closed raised SIGPIPE and killed Loop
(LoopKit/TrueTime.swift#6).
ps2 added a commit to LoopKit/LoopWorkspace that referenced this pull request Dec 1, 2026
…outService, MinimedKit, MedtrumKit, LibreTransmitter and TrueTime.swift; add GlookoService (#595)

* Bump Loop and OmnipodKit for watch plugin loading

Loop: the watch app loads its CGM kit at run time (LoopKit/Loop#2693), and
HealthKit authorization no longer blocks the main thread (LoopKit/Loop#2684).
OmnipodKit: the watch can load OmnipodKit at run time
(loopandlearn/OmnipodKit#225).

* Bump G7SensorKit for run-time watch loading and early control notifications

The watch loads G7SensorKit at run time (LoopKit/G7SensorKit#110), which the
Loop watch app change in LoopKit/Loop#2693 depends on. Control notifications
are enabled before authentication when eavesdropping (LoopKit/G7SensorKit#126).

* Bump G7SensorKit to include run-time watch loading

The previous bump stopped at LoopKit/G7SensorKit#126; next-dev's tip is
LoopKit/G7SensorKit#110, which the Loop watch app change depends on.

* Bump TrueTime.swift to ignore SIGPIPE on its sockets

A write to a socket the server had closed raised SIGPIPE and killed Loop
(LoopKit/TrueTime.swift#6).

* Add GlookoService

Adds Nutcasey/GlookoService at 459dc9d as a submodule, its project to the
workspace and GlookoServiceKitPlugin to the LoopWorkspace scheme.

* Bump G7SensorKit, LoopKit, Loop, TidepoolService and GlookoService

- G7SensorKit to c86d9bb: a link that delivered a reading isn't a stopped
  session (#127), rescan after a 2 s sleep and connect when another app
  connects (#130), reissue the connect at power-on after a restore (#134),
  and a new sensor or code from the phone keeps the watch's session (#128)
- LoopKit to bf8710f2: a device several controllers use can take a changed
  configuration in place (#706)
- Loop to 60007b90: active services in the Issue Report (#2700)
- TidepoolService to 365f124: pump component changes upload as
  reservoirChange and cannula prime events (#51)
- GlookoService to 8349aa0: three alerts instead of twelve, localised text

* Bump LoopKit, OmnipodKit, TidepoolService and NightscoutService for component replacement

- LoopKit to 4e2b9c50: pump events carry component replacement details
  (LoopKit/LoopKit#703)
- OmnipodKit to 681d4cc: the pod change is described with a
  ComponentReplacement (loopandlearn/OmnipodKit#224)
- TidepoolService to 71cc679: uploads the replacement details instead of
  decoding raw data (LoopKit/TidepoolService#52)
- NightscoutService to 6952920: Site Change notes include the replacement
  reason (LoopKit/NightscoutService#52)

* update Glooko: Add Glooko regions: United States, Canada, Germany and France, improve logging

* update Script/define_common to include GlookoService

* fix: update Script/define_common for next-dev branches

* Bump G7SensorKit for early setup from didConnect, the start-delay reconnect and the link hold

LoopKit/G7SensorKit#135 and LoopKit/G7SensorKit#138.

* Bump Loop, LoopKit, OmnipodKit, MinimedKit, MedtrumKit, G7SensorKit, LibreTransmitter and TrueTime.swift

- Loop, LoopKit, OmnipodKit, MinimedKit and MedtrumKit: the watch shows the
  current pump reservoir level from pump status (LoopKit/Loop#2706,
  LoopKit/LoopKit#709, loopandlearn/OmnipodKit#230, LoopKit/MinimedKit#50,
  LoopKit/MedtrumKit#13)
- Loop: reset the Presets icon when a restored preset expires
  (LoopKit/Loop#2685); watch layout moves up with Active Insulin first
  (LoopKit/Loop#2670)
- LoopKit: the preset ISF preview gets a per-unit quantity (LoopKit/LoopKit#711)
- G7SensorKit: a failed sensor shows as a row instead of its raw state name
  (LoopKit/G7SensorKit#142)
- LibreTransmitter: glucose algorithm robustness (LoopKit/LibreTransmitter#66);
  Libre 2 EU sensors with the new patch info first byte pair
  (LoopKit/LibreTransmitter#67)
- TrueTime.swift: iOS deployment target 15.0 (LoopKit/TrueTime.swift#4)

---------

Co-authored-by: marionbarker <marionbarker@earthlink.net>
LucasSHYC pushed a commit to LucasSHYC/LoopWorkspace that referenced this pull request Dec 2, 2026
5dc1285f...a9fee6a4
- Discard NTP replies whose round trip exceeds the timeout (LoopKit/TrueTime.swift#5)
- Don't raise SIGPIPE when sending on a defunct NTP socket (LoopKit/TrueTime.swift#6)
- Update iOS deployment target to 15.0 (LoopKit/TrueTime.swift#4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant