| 1492 | } |
| 1493 | |
| 1494 | void finished(const Future<vector<Option<int>>>& future) |
| 1495 | { |
| 1496 | if (future.isDiscarded()) { |
| 1497 | promise.fail("Unexpected discard of future"); |
| 1498 | terminate(self()); |
| 1499 | return; |
| 1500 | } else if (future.isFailed()) { |
| 1501 | // If the `cgroup` still exists in the hierarchy, treat this as |
| 1502 | // an error; otherwise, treat this as a success since the `cgroup` |
| 1503 | // has actually been cleaned up. |
| 1504 | if (os::exists(path::join(hierarchy, cgroup))) { |
| 1505 | promise.fail(future.failure()); |
| 1506 | } else { |
| 1507 | promise.set(Nothing()); |
| 1508 | } |
| 1509 | |
| 1510 | terminate(self()); |
| 1511 | return; |
| 1512 | } |
| 1513 | |
| 1514 | // Verify the cgroup is now empty. |
| 1515 | Try<set<pid_t>> processes = cgroups::processes(hierarchy, cgroup); |
| 1516 | |
| 1517 | // If the `cgroup` is already removed, treat this as a success. |
| 1518 | if ((processes.isError() || !processes->empty()) && |
| 1519 | os::exists(path::join(hierarchy, cgroup))) { |
| 1520 | promise.fail("Failed to kill all processes in cgroup: " + |
| 1521 | (processes.isError() ? processes.error() |
| 1522 | : "processes remain")); |
| 1523 | terminate(self()); |
| 1524 | return; |
| 1525 | } |
| 1526 | |
| 1527 | promise.set(Nothing()); |
| 1528 | terminate(self()); |
| 1529 | } |
| 1530 | |
| 1531 | const string hierarchy; |
| 1532 | const string cgroup; |
nothing calls this directly
no test coverage detected