7 #include <winapi/handle.hpp>
8 #include <winapi/pipe.hpp>
18 void create_pipe(Handle& read_end, Handle& write_end) {
19 HANDLE read_end_impl = INVALID_HANDLE_VALUE;
20 HANDLE write_end_impl = INVALID_HANDLE_VALUE;
22 SECURITY_ATTRIBUTES attributes;
23 std::memset(&attributes, 0,
sizeof(attributes));
24 attributes.nLength =
sizeof(attributes);
25 attributes.bInheritHandle = TRUE;
27 static constexpr DWORD buffer_size = 16 * 1024;
29 const auto ret = ::CreatePipe(&read_end_impl, &write_end_impl, &attributes, buffer_size);
32 throw error::windows(GetLastError(),
"CreatePipe");
35 read_end = Handle{read_end_impl};
36 write_end = Handle{write_end_impl};
42 create_pipe(m_read_end, m_write_end);
Make std::system_error work with GetLastError().