| 269 | } |
| 270 | |
| 271 | void file::pipe(file& read_end, file& write_end) { |
| 272 | // Close the descriptors first to make sure that assignments don't throw |
| 273 | // and there are no leaks. |
| 274 | read_end.close(); |
| 275 | write_end.close(); |
| 276 | int fds[2] = {}; |
| 277 | # ifdef _WIN32 |
| 278 | // Make the default pipe capacity same as on Linux 2.6.11+. |
| 279 | enum { DEFAULT_CAPACITY = 65536 }; |
| 280 | int result = FMT_POSIX_CALL(pipe(fds, DEFAULT_CAPACITY, _O_BINARY)); |
| 281 | # else |
| 282 | // Don't retry as the pipe function doesn't return EINTR. |
| 283 | // http://pubs.opengroup.org/onlinepubs/009696799/functions/pipe.html |
| 284 | int result = FMT_POSIX_CALL(pipe(fds)); |
| 285 | # endif |
| 286 | if (result != 0) FMT_THROW(system_error(errno, "cannot create pipe")); |
| 287 | // The following assignments don't throw because read_fd and write_fd |
| 288 | // are closed. |
| 289 | read_end = file(fds[0]); |
| 290 | write_end = file(fds[1]); |
| 291 | } |
| 292 | |
| 293 | buffered_file file::fdopen(const char* mode) { |
| 294 | // Don't retry as fdopen doesn't return EINTR. |
nothing calls this directly
no test coverage detected