| 967 | |
| 968 | |
| 969 | void CheckerProcess::processCommandCheckResult( |
| 970 | const Stopwatch& stopwatch, |
| 971 | const Future<int>& future) |
| 972 | { |
| 973 | CHECK(!future.isPending()); |
| 974 | |
| 975 | Result<CheckStatusInfo> result = None(); |
| 976 | |
| 977 | // On Posix, `future` corresponds to termination information in the |
| 978 | // `stat_loc` area. On Windows, `status` is obtained via calling the |
| 979 | // `GetExitCodeProcess()` function. |
| 980 | // |
| 981 | // TODO(alexr): Ensure `WEXITSTATUS` family macros are no-op on Windows, |
| 982 | // see MESOS-7242. |
| 983 | if (future.isReady() && WIFEXITED(future.get())) { |
| 984 | const int exitCode = WEXITSTATUS(future.get()); |
| 985 | LOG(INFO) << name << " for task '" << taskId << "' returned: " << exitCode; |
| 986 | |
| 987 | CheckStatusInfo checkStatusInfo; |
| 988 | checkStatusInfo.set_type(CheckInfo::COMMAND); |
| 989 | checkStatusInfo.mutable_command()->set_exit_code( |
| 990 | static_cast<int32_t>(exitCode)); |
| 991 | |
| 992 | result = Result<CheckStatusInfo>(checkStatusInfo); |
| 993 | } else if (future.isDiscarded()) { |
| 994 | // Check's status is currently not available due to a transient error, |
| 995 | // e.g., due to the agent failover, no `CheckStatusInfo` message should |
| 996 | // be sent to the callback. |
| 997 | result = None(); |
| 998 | } else { |
| 999 | result = Result<CheckStatusInfo>(Error(future.failure())); |
| 1000 | } |
| 1001 | |
| 1002 | processCheckResult(stopwatch, result); |
| 1003 | } |
| 1004 | |
| 1005 | static vector<string> httpCheckCommand( |
| 1006 | const string& command, |