MCPcopy Create free account
hub / github.com/arun11299/cpp-subprocess / wait

Method wait

cpp-subprocess/subprocess.hpp:1546–1577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1544}
1545
1546inline int Popen::wait() noexcept(false)
1547{
1548#ifdef __USING_WINDOWS__
1549 int ret = WaitForSingleObject(process_handle_, INFINITE);
1550
1551 // WaitForSingleObject with INFINITE should only return when process has signaled
1552 if (ret != WAIT_OBJECT_0) {
1553 throw OSError("Unexpected return code from WaitForSingleObject", 0);
1554 }
1555
1556 DWORD dretcode_;
1557
1558 if (FALSE == GetExitCodeProcess(process_handle_, &dretcode_))
1559 throw OSError("Failed during call to GetExitCodeProcess", 0);
1560
1561 CloseHandle(process_handle_);
1562
1563 return (int)dretcode_;
1564#else
1565 int ret, status;
1566 std::tie(ret, status) = util::wait_for_child_exit(pid());
1567 if (ret == -1) {
1568 if (errno != ECHILD) throw OSError("waitpid failed", errno);
1569 return 0;
1570 }
1571 if (WIFEXITED(status)) return WEXITSTATUS(status);
1572 if (WIFSIGNALED(status)) return WTERMSIG(status);
1573 else return 255;
1574
1575 return 0;
1576#endif
1577}
1578
1579inline int Popen::poll() noexcept(false)
1580{

Callers 3

test_cat_send_terminateFunction · 0.80
test_envFunction · 0.80
call_implFunction · 0.80

Calls 2

OSErrorClass · 0.85
wait_for_child_exitFunction · 0.85

Tested by 2

test_cat_send_terminateFunction · 0.64
test_envFunction · 0.64