MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / pipe

Method pipe

extlibs/fmt/src/os.cc:271–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271void 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
293buffered_file file::fdopen(const char* mode) {
294 // Don't retry as fdopen doesn't return EINTR.

Callers

nothing calls this directly

Calls 3

system_errorFunction · 0.85
fileClass · 0.85
closeMethod · 0.45

Tested by

no test coverage detected