MCPcopy Create free account
hub / github.com/Icinga/icinga2 / CreatePipeOverlapped

Function CreatePipeOverlapped

lib/base/process.cpp:765–794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

763
764#ifdef _WIN32
765static BOOL CreatePipeOverlapped(HANDLE *outReadPipe, HANDLE *outWritePipe,
766 SECURITY_ATTRIBUTES *securityAttributes, DWORD size, DWORD readMode, DWORD writeMode)
767{
768 static LONG pipeIndex = 0;
769
770 if (size == 0)
771 size = 8192;
772
773 LONG currentIndex = InterlockedIncrement(&pipeIndex);
774
775 char pipeName[128];
776 sprintf(pipeName, "\\\\.\\Pipe\\OverlappedPipe.%d.%d", (int)GetCurrentProcessId(), (int)currentIndex);
777
778 *outReadPipe = CreateNamedPipe(pipeName, PIPE_ACCESS_INBOUND | readMode,
779 PIPE_TYPE_BYTE | PIPE_WAIT, 1, size, size, 60 * 1000, securityAttributes);
780
781 if (*outReadPipe == INVALID_HANDLE_VALUE)
782 return FALSE;
783
784 *outWritePipe = CreateFile(pipeName, GENERIC_WRITE, 0, securityAttributes, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | writeMode, nullptr);
785
786 if (*outWritePipe == INVALID_HANDLE_VALUE) {
787 DWORD error = GetLastError();
788 CloseHandle(*outReadPipe);
789 SetLastError(error);
790 return FALSE;
791 }
792
793 return TRUE;
794}
795#endif /* _WIN32 */
796
797void Process::Run(const std::function<void(const ProcessResult&)>& callback)

Callers 1

RunMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected