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

Method Run

lib/base/process.cpp:797–1031  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

795#endif /* _WIN32 */
796
797void Process::Run(const std::function<void(const ProcessResult&)>& callback)
798{
799#ifndef _WIN32
800 boost::call_once(l_SpawnHelperOnceFlag, &Process::InitializeSpawnHelper);
801#endif /* _WIN32 */
802 boost::call_once(l_ProcessOnceFlag, &Process::ThreadInitialize);
803
804 m_Result.ExecutionStart = Utility::GetTime();
805
806#ifdef _WIN32
807 SECURITY_ATTRIBUTES sa = {};
808 sa.nLength = sizeof(sa);
809 sa.bInheritHandle = TRUE;
810
811 HANDLE outReadPipe, outWritePipe;
812 if (!CreatePipeOverlapped(&outReadPipe, &outWritePipe, &sa, 0, FILE_FLAG_OVERLAPPED, 0))
813 BOOST_THROW_EXCEPTION(win32_error()
814 << boost::errinfo_api_function("CreatePipe")
815 << errinfo_win32_error(GetLastError()));
816
817 if (!SetHandleInformation(outReadPipe, HANDLE_FLAG_INHERIT, 0))
818 BOOST_THROW_EXCEPTION(win32_error()
819 << boost::errinfo_api_function("SetHandleInformation")
820 << errinfo_win32_error(GetLastError()));
821
822 HANDLE outWritePipeDup;
823 if (!DuplicateHandle(GetCurrentProcess(), outWritePipe, GetCurrentProcess(),
824 &outWritePipeDup, 0, TRUE, DUPLICATE_SAME_ACCESS))
825 BOOST_THROW_EXCEPTION(win32_error()
826 << boost::errinfo_api_function("DuplicateHandle")
827 << errinfo_win32_error(GetLastError()));
828
829/* LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList;
830 SIZE_T cbSize;
831
832 if (!InitializeProcThreadAttributeList(nullptr, 1, 0, &cbSize) && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
833 BOOST_THROW_EXCEPTION(win32_error()
834 << boost::errinfo_api_function("InitializeProcThreadAttributeList")
835 << errinfo_win32_error(GetLastError()));
836
837 lpAttributeList = reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(new char[cbSize]);
838
839 if (!InitializeProcThreadAttributeList(lpAttributeList, 1, 0, &cbSize))
840 BOOST_THROW_EXCEPTION(win32_error()
841 << boost::errinfo_api_function("InitializeProcThreadAttributeList")
842 << errinfo_win32_error(GetLastError()));
843
844 HANDLE rgHandles[3];
845 rgHandles[0] = outWritePipe;
846 rgHandles[1] = outWritePipeDup;
847 rgHandles[2] = GetStdHandle(STD_INPUT_HANDLE);
848
849 if (!UpdateProcThreadAttribute(lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_HANDLE_LIST,
850 rgHandles, sizeof(rgHandles), nullptr, nullptr))
851 BOOST_THROW_EXCEPTION(win32_error()
852 << boost::errinfo_api_function("UpdateProcThreadAttribute")
853 << errinfo_win32_error(GetLastError()));
854*/

Callers 5

TryActivateZonesStageMethod · 0.45
AsyncTryActivateStageMethod · 0.45
ExecuteCommandMethod · 0.45
icinga.cppFile · 0.45
MainMethod · 0.45

Calls 9

CreatePipeOverlappedFunction · 0.85
win32_errorClass · 0.85
LogClass · 0.85
posix_errorClass · 0.85
ProcessSpawnFunction · 0.85
CStrMethod · 0.80
StringClass · 0.70
GetLengthMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected