Refactored stout os open/close/fcntl.

Review: https://reviews.apache.org/r/26843