| 70 | |
| 71 | |
| 72 | Future<size_t> write(int_fd fd, const void* data, size_t size) |
| 73 | { |
| 74 | process::initialize(); |
| 75 | |
| 76 | // Check the file descriptor. |
| 77 | Try<bool> async = is_async(fd); |
| 78 | if (async.isError()) { |
| 79 | // The file descriptor is not valid (e.g., has been closed). |
| 80 | return Failure( |
| 81 | "Failed to check if file descriptor was asynchronous: " + |
| 82 | async.error()); |
| 83 | } else if (!async.get()) { |
| 84 | return Failure("Expected an asynchronous file descriptor."); |
| 85 | } |
| 86 | |
| 87 | return internal::write(fd, data, size); |
| 88 | } |
| 89 | |
| 90 | |
| 91 | namespace internal { |