Open
Description
Is your feature request related to a problem? Please describe.
The server sets stdout to be non-blocking which messes terminals. (fd's tied to tty).
Describe the solution you'd like
Ensure the O_NONBLOCK
flag is returned to its previous state when the server stops.
Describe alternatives you've considered
For now I'm doing something quick and dirty like this on shutdown of the server loop:
/// Attempt to set FileDescriptor to blocking mode ignoring errors
func attemptSetBlocking(fileDescriptor: FileDescriptor) {
let flags = fcntl(fileDescriptor.rawValue, F_GETFL)
guard flags >= 0 else {
return
}
let _ = fcntl(fileDescriptor.rawValue, F_SETFL, flags ^ O_NONBLOCK)
}