| 826 | |
| 827 | |
| 828 | Try<Nothing> kill( |
| 829 | const string& hierarchy, |
| 830 | const string& cgroup, |
| 831 | int signal) |
| 832 | { |
| 833 | Try<set<pid_t>> pids = processes(hierarchy, cgroup); |
| 834 | if (pids.isError()) { |
| 835 | return Error("Failed to get processes of cgroup: " + pids.error()); |
| 836 | } |
| 837 | |
| 838 | foreach (pid_t pid, pids.get()) { |
| 839 | if (::kill(pid, signal) == -1) { |
| 840 | // If errno is set to ESRCH, it means that either a) this process already |
| 841 | // terminated, or b) it's in a 'zombie' state and we can't signal it |
| 842 | // anyway. In either case, ignore the error. |
| 843 | if (errno != ESRCH) { |
| 844 | return ErrnoError( |
| 845 | "Failed to send " + string(strsignal(signal)) + |
| 846 | " to process " + stringify(pid)); |
| 847 | } |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | return Nothing(); |
| 852 | } |
| 853 | |
| 854 | |
| 855 | Try<string> read( |