killall.c revision 1359fffa573f42463e3b369df5e57b0c33821a61
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers This file is part of systemd.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers Copyright 2010 ProFUSION embedded systems
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers systemd is free software; you can redistribute it and/or modify it
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers under the terms of the GNU Lesser General Public License as published by
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers the Free Software Foundation; either version 2.1 of the License, or
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers (at your option) any later version.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers systemd is distributed in the hope that it will be useful, but
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers WITHOUT ANY WARRANTY; without even the implied warranty of
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers Lesser General Public License for more details.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers You should have received a copy of the GNU Lesser General Public License
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers along with systemd; If not, see <http://www.gnu.org/licenses/>.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sieversstatic bool ignore_proc(pid_t pid, bool warn_rootfs) {
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers const char *p;
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers /* We are PID 1, let's not commit suicide */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers return true;
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers return true; /* not really, but better safe than sorry */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers /* Non-root processes otherwise are always subject to be killed */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers return false;
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers return true; /* not really, but has the desired effect */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers /* Kernel threads have an empty cmdline */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers return true;
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers /* Processes with argv[0][0] = '@' we ignore from the killing
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers return true;
usec_t n;
Iterator i;
if (pid == 0)
if (pid < 0) {
if (n >= until)
if (k != SIGCHLD) {
struct dirent *d;
if (!dir)
return -errno;
if (pids) {
log_oom();
if (send_sighup) {
if (wait_for_exit)
if (wait_for_exit)