Skip to content

Commit 0f4947e

Browse files
committed
Pull request #7: [MDAPI-117] fix sig_pipe crash
Merge in MDAPI/dxfeed-graal-swift-api from feature/MDAPI-117-swift-handle-sigpipe-for-ws-connection to main Squashed commit of the following: commit d518727e5f8757d2cc9dd4f91c75d0ecad328e48 Author: Aleksey Kosylo <[email protected]> Date: Thu Aug 1 14:22:45 2024 +0200 [MDAPI-117] fix sig_pipe crash
1 parent 1836d01 commit 0f4947e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

DXFeedFramework/Native/Graal/Isolate.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ class Isolate {
7171
graal_detach_all_threads_and_tear_down_isolate(self.thread.pointee)
7272
}
7373
}
74+
// When called, this signal handler simulates a function call to `callThreadExit`
75+
private func sigIllHandler(code: Int32, info: UnsafeMutablePointer<siginfo_t>?, uap: UnsafeMutableRawPointer?) -> Void {
76+
print("Handle signal \(code)")
77+
}
7478

7579
/// Isolate should be initialized in main thread to avoid problem with overcommited queues.
7680
///
@@ -86,6 +90,16 @@ class Isolate {
8690
#else
8791
print("FEED SDK: Release")
8892
#endif
93+
var sigActionPrev = sigaction()
94+
// Get the previous signal action
95+
if sigaction(SIGPIPE, nil, &sigActionPrev) != 0 {
96+
print("Sigaction error: \(errno)")
97+
} else {
98+
if sigActionPrev.__sigaction_u.__sa_handler == nil {
99+
signal(SIGPIPE, SIG_IGN)
100+
}
101+
}
102+
89103
osThread.qualityOfService = .userInteractive
90104
waiter.enter()
91105
osThread.start()

0 commit comments

Comments
 (0)