MCPcopy Create free account
hub / github.com/AGWA/git-crypt / spawn_command

Function spawn_command

coprocess-win32.cpp:83–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83static HANDLE spawn_command (const std::vector<std::string>& command, HANDLE stdin_handle, HANDLE stdout_handle, HANDLE stderr_handle)
84{
85 PROCESS_INFORMATION proc_info;
86 ZeroMemory(&proc_info, sizeof(proc_info));
87
88 STARTUPINFO start_info;
89 ZeroMemory(&start_info, sizeof(start_info));
90
91 start_info.cb = sizeof(STARTUPINFO);
92 start_info.hStdInput = stdin_handle ? stdin_handle : GetStdHandle(STD_INPUT_HANDLE);
93 start_info.hStdOutput = stdout_handle ? stdout_handle : GetStdHandle(STD_OUTPUT_HANDLE);
94 start_info.hStdError = stderr_handle ? stderr_handle : GetStdHandle(STD_ERROR_HANDLE);
95 start_info.dwFlags |= STARTF_USESTDHANDLES;
96
97 std::string cmdline(format_cmdline(command));
98
99 if (!CreateProcessA(nullptr, // application name (nullptr to use command line)
100 const_cast<char*>(cmdline.c_str()),
101 nullptr, // process security attributes
102 nullptr, // primary thread security attributes
103 TRUE, // handles are inherited
104 0, // creation flags
105 nullptr, // use parent's environment
106 nullptr, // use parent's current directory
107 &start_info,
108 &proc_info)) {
109 throw System_error("CreateProcess", cmdline, GetLastError());
110 }
111
112 CloseHandle(proc_info.hThread);
113
114 return proc_info.hProcess;
115}
116
117
118Coprocess::Coprocess ()

Callers 1

spawnMethod · 0.85

Calls 2

format_cmdlineFunction · 0.85
System_errorClass · 0.85

Tested by

no test coverage detected