| 1072 | } |
| 1073 | |
| 1074 | void escalated(const Duration& timeout) |
| 1075 | { |
| 1076 | if (terminated) { |
| 1077 | return; |
| 1078 | } |
| 1079 | |
| 1080 | CHECK_SOME(pid); |
| 1081 | |
| 1082 | LOG(INFO) << "Process " << pid.get() << " did not terminate after " |
| 1083 | << timeout << ", sending SIGKILL to process tree at " |
| 1084 | << pid.get(); |
| 1085 | |
| 1086 | // TODO(nnielsen): Sending SIGTERM in the first stage of the |
| 1087 | // shutdown may leave orphan processes hanging off init. This |
| 1088 | // scenario will be handled when PID namespace encapsulated |
| 1089 | // execution is in place. |
| 1090 | Try<std::list<os::ProcessTree>> trees = |
| 1091 | os::killtree(pid.get(), SIGKILL, true, true); |
| 1092 | |
| 1093 | if (trees.isError()) { |
| 1094 | LOG(ERROR) << "Failed to kill the process tree rooted at pid " |
| 1095 | << pid.get() << ": " << trees.error(); |
| 1096 | |
| 1097 | // Process 'pid' may not have received signal before |
| 1098 | // os::killtree() failed. To make sure process 'pid' is reaped |
| 1099 | // we send SIGKILL directly. |
| 1100 | os::kill(pid.get(), SIGKILL); |
| 1101 | } else { |
| 1102 | LOG(INFO) << "Killed the following process trees:\n" |
| 1103 | << stringify(trees.get()); |
| 1104 | } |
| 1105 | } |
| 1106 | |
| 1107 | |
| 1108 | void taskCompletionTimeout(const TaskID& taskId, const Duration& duration) |