<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I am trying to catch SIGWINCH (terminal window size changed) in Swift 3 (Xcode 8). The following code should exit with a status of 1 when it receives SIGWINCH. But it never exits.</div><div class=""><br class=""></div><div class="">```swift</div><div class=""><font face="Menlo" color="#5e30eb" class="">// compile with `xcrun -sdk macosx swiftc sigwinch.swift`</font></div><div class=""><font face="Menlo" color="#5e30eb" class=""><br class=""></font></div><div class=""><font face="Menlo" color="#5e30eb" class="">import Darwin</font></div><div class=""><font face="Menlo" color="#5e30eb" class="">import Dispatch</font></div><div class=""><font face="Menlo" color="#5e30eb" class=""><br class=""></font></div><div class=""><font face="Menlo" color="#5e30eb" class="">let source = DispatchSource.signal(signal: SIGWINCH, queue: DispatchQueue.main)</font></div><div class=""><font face="Menlo" color="#5e30eb" class="">source.setEventHandler {</font></div><div class=""><font face="Menlo" color="#5e30eb" class=""> exit(1)</font></div><div class=""><font face="Menlo" color="#5e30eb" class="">}</font></div><div class=""><font face="Menlo" color="#5e30eb" class="">source.resume()</font></div><div class=""><font face="Menlo" color="#5e30eb" class=""><br class=""></font></div><div class=""><font face="Menlo" color="#5e30eb" class="">dispatchMain()</font></div><div class="">```</div><div class=""><br class=""></div><div class="">The equivalent Objective-C code works as expected.</div><div class=""><br class=""></div><div class="">```objc</div><div class=""><div class=""><font face="Menlo" color="#4f7a28" class="">// compile with `xcrun -sdk macosx clang sigwinch.m`</font></div><div class=""><font face="Menlo" color="#4f7a28" class=""><br class=""></font></div><div class=""><font face="Menlo" color="#4f7a28" class="">#import <dispatch/dispatch.h></font></div><div class=""><font face="Menlo" color="#4f7a28" class="">#import <signal.h></font></div><div class=""><font face="Menlo" color="#4f7a28" class="">#import <stdlib.h></font></div><div class=""><font face="Menlo" color="#4f7a28" class=""><br class=""></font></div><div class=""><font face="Menlo" color="#4f7a28" class="">int main() {</font></div><div class=""><font face="Menlo" color="#4f7a28" class=""> dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL,</font></div><div class=""><font face="Menlo" color="#4f7a28" class=""> SIGWINCH,</font></div><div class=""><font face="Menlo" color="#4f7a28" class=""> 0,</font></div><div class=""><font face="Menlo" color="#4f7a28" class=""> dispatch_get_main_queue());</font></div><div class=""><font face="Menlo" color="#4f7a28" class=""> dispatch_source_set_event_handler(source, ^{</font></div><div class=""><font face="Menlo" color="#4f7a28" class=""> exit(1);</font></div><div class=""><font face="Menlo" color="#4f7a28" class=""> });</font></div><div class=""><font face="Menlo" color="#4f7a28" class=""> dispatch_resume(source);</font></div><div class=""><font face="Menlo" color="#4f7a28" class=""><br class=""></font></div><div class=""><font face="Menlo" color="#4f7a28" class=""> dispatch_main();</font></div><div class=""><font face="Menlo" color="#4f7a28" class="">}</font></div></div><div class="">```</div><div class=""><br class=""></div><div class="">What am I doing wrong?</div></body></html>