Skip to content

Commit 7cee8ba

Browse files
committed
[Macros] Termination signal for executable plugin
Exit the plugin when it receives an empty message. rdar://160820381
1 parent 8ea19b6 commit 7cee8ba

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/SwiftCompilerPluginMessageHandling/StandardIOMessageConnection.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ public struct StandardIOMessageConnection: MessageConnection {
152152

153153
// Read the JSON payload.
154154
let count = Int(UInt64(littleEndian: header))
155+
// Empty message is a termination signal.
156+
if count == 0 {
157+
return nil
158+
}
155159
let data = UnsafeMutableRawBufferPointer.allocate(byteCount: count, alignment: 1)
156160
defer { data.deallocate() }
157161
try _read(into: data)

0 commit comments

Comments
 (0)