Data(contentsOf:) fails on Linux where it doesn't on macOS

You are right, I mistakenly thought that signal on the awoken DispatchSemaphore is ignored (as would be in the binary semaphore).

Why the code doesn't work for you remains a mystery, looks like URLSession bug on linux.