MCPcopy Create free account
hub / github.com/Kitware/CMake / kwsysProcessGetTimeoutLeft

Function kwsysProcessGetTimeoutLeft

Source/kwsys/ProcessUNIX.c:2025–2053  ·  view source on GitHub ↗

Get the length of time before the given timeout time arrives. Returns 1 if the time has already arrived, and 0 otherwise. */

Source from the content-addressed store, hash-verified

2023/* Get the length of time before the given timeout time arrives.
2024 Returns 1 if the time has already arrived, and 0 otherwise. */
2025static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
2026 double const* userTimeout,
2027 kwsysProcessTimeNative* timeoutLength,
2028 int zeroIsExpired)
2029{
2030 if (timeoutTime->tv_sec < 0) {
2031 /* No timeout time has been requested. */
2032 return 0;
2033 }
2034 /* Calculate the remaining time. */
2035 kwsysProcessTime currentTime = kwsysProcessTimeGetCurrent();
2036 kwsysProcessTime timeLeft =
2037 kwsysProcessTimeSubtract(*timeoutTime, currentTime);
2038 if (timeLeft.tv_sec < 0 && userTimeout && *userTimeout <= 0) {
2039 /* Caller has explicitly requested a zero timeout. */
2040 timeLeft.tv_sec = 0;
2041 timeLeft.tv_usec = 0;
2042 }
2043
2044 if (timeLeft.tv_sec < 0 ||
2045 (timeLeft.tv_sec == 0 && timeLeft.tv_usec == 0 && zeroIsExpired)) {
2046 /* Timeout has already expired. */
2047 return 1;
2048 }
2049 /* There is some time left. */
2050 timeoutLength->tv_sec = timeLeft.tv_sec;
2051 timeoutLength->tv_usec = timeLeft.tv_usec;
2052 return 0;
2053}
2054
2055static kwsysProcessTime kwsysProcessTimeGetCurrent(void)
2056{

Callers 1

kwsysProcessWaitForPipeFunction · 0.70

Calls 2

kwsysProcessTimeSubtractFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…