Skip to content

Commit

Permalink
Use atexit on Linux
Browse files Browse the repository at this point in the history
Fixes #3214
  • Loading branch information
marcelofabri committed Aug 5, 2020
1 parent 8638d23 commit caedfcb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
[Marcelo Fabri](https://github.com/marcelofabri)
[#3225](https://github.com/realm/SwiftLint/issues/3225)

* Fix some cases where the output would be incomplete when running
SwiftLint on Linux.
[Marcelo Fabri](https://github.com/marcelofabri)
[#3214](https://github.com/realm/SwiftLint/issues/3214)

## 0.39.2: Stay Home

This is the last release to support building with Swift 5.0.x.
Expand Down
12 changes: 8 additions & 4 deletions Source/SwiftLintFramework/Extensions/QueuedPrint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ private let outputQueue: DispatchQueue = {
target: .global(qos: .userInteractive)
)

#if !os(Linux)
atexit_b {
queue.sync(flags: .barrier) {}
defer {
setupAtExitHandler()
}
#endif

return queue
}()

private func setupAtExitHandler() {
atexit {
outputQueue.sync(flags: .barrier) {}
}
}

/**
A thread-safe version of Swift's standard `print()`.
Expand Down

0 comments on commit caedfcb

Please sign in to comment.