Skip to content

Return file descriptor mode to original state wrt O_NONBLOCK #69

Closed

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

Activity

  1. added
    enhancement
    on Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions