2
* Copyright © 2014 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License along
14
* with this program. If not, see <http://www.gnu.org/licenses/>.
17
* Ted Gould <ted.gould@canonical.com>
22
int kill (pid_t pid, int signal);
23
pid_t getpgid (pid_t);
26
main (int argc, char * argv[])
28
/* Break off a new process group */
31
GDBusConnection * cgmanager = cgroup_manager_connection();
32
g_return_val_if_fail(cgmanager != NULL, -1);
34
/* We're gonna try to kill things forever, literally. It's important
35
enough that we can't consider failure an option. */
36
gboolean killed = TRUE;
38
GList * pidlist = pids_from_cgroup(cgmanager, NULL, NULL);
43
for (head = pidlist; head != NULL; head = g_list_next(head)) {
44
GPid pid = GPOINTER_TO_INT(head->data);
46
/* We don't want to kill ourselves, or if we're being executed by
47
a script, that script, either. We also don't want things in our
48
process group which we forked at the opening */
49
if (pid != getpid() && pid != getppid() && getpgid(pid) != getpid()) {
50
g_debug("Killing pid: %d", pid);
59
g_clear_object(&cgmanager);