MCPcopy Create free account
hub / github.com/HowardHinnant/date / run_program

Function run_program

src/tz.cpp:3571–3597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3569
3570# if !USE_SHELL_API
3571static
3572int
3573run_program(const std::string& command)
3574{
3575 STARTUPINFO si{};
3576 si.cb = sizeof(si);
3577 PROCESS_INFORMATION pi{};
3578
3579 // Allegedly CreateProcess overwrites the command line. Ugh.
3580 std::string mutable_command(command);
3581 if (CreateProcess(nullptr, &mutable_command[0],
3582 nullptr, nullptr, FALSE, CREATE_NO_WINDOW, nullptr, nullptr, &si, &pi))
3583 {
3584 WaitForSingleObject(pi.hProcess, INFINITE);
3585 DWORD exit_code;
3586 bool got_exit_code = !!GetExitCodeProcess(pi.hProcess, &exit_code);
3587 CloseHandle(pi.hProcess);
3588 CloseHandle(pi.hThread);
3589 // Not 100% sure about this still active thing is correct,
3590 // but I'm going with it because I *think* WaitForSingleObject might
3591 // return in some cases without INFINITE-ly waiting.
3592 // But why/wouldn't GetExitCodeProcess return false in that case?
3593 if (got_exit_code && exit_code != STILL_ACTIVE)
3594 return static_cast<int>(exit_code);
3595 }
3596 return EXIT_FAILURE;
3597}
3598# endif // !USE_SHELL_API
3599
3600static

Callers 1

extract_gz_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected