Skip to content

Return file descriptor mode to original state wrt O_NONBLOCK #69

Open
@toffaletti

Description

@toffaletti

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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions