MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / Pipe

Function Pipe

Bcore/src/main/cpp/android-base/unique_fd.h:101–123  ·  view source on GitHub ↗

Inline functions, so that they can be used header-only.

Source from the content-addressed store, hash-verified

99
100// Inline functions, so that they can be used header-only.
101inline bool Pipe(unique_fd* read, unique_fd* write) {
102 int pipefd[2];
103
104#if defined(__linux__)
105 if (pipe2(pipefd, O_CLOEXEC) != 0) {
106 return false;
107 }
108#else // defined(__APPLE__)
109 if (pipe(pipefd) != 0) {
110 return false;
111 }
112
113 if (fcntl(pipefd[0], F_SETFD, FD_CLOEXEC) != 0 || fcntl(pipefd[1], F_SETFD, FD_CLOEXEC) != 0) {
114 close(pipefd[0]);
115 close(pipefd[1]);
116 return false;
117 }
118#endif
119
120 read->reset(pipefd[0]);
121 write->reset(pipefd[1]);
122 return true;
123}
124
125inline bool Socketpair(int domain, int type, int protocol, unique_fd* left, unique_fd* right) {
126 int sockfd[2];

Callers

nothing calls this directly

Calls 1

resetMethod · 0.45

Tested by

no test coverage detected