2008-09-24 17:38:00 +02:00
|
|
|
--- src/killall5.c
|
2008-10-06 17:17:04 +02:00
|
|
|
+++ src/killall5.c 2008-10-01 18:05:29.829808878 +0200
|
|
|
|
@@ -456,6 +456,39 @@ int readproc()
|
2008-09-24 17:38:00 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * Scan the filedescriptors of pid for /dev/fuse
|
|
|
|
+ */
|
|
|
|
+int is_fuse(int pid) {
|
|
|
|
+ DIR *dir;
|
|
|
|
+ char path[256];
|
|
|
|
+ char buf[256];
|
|
|
|
+ struct dirent *d;
|
|
|
|
+ ssize_t len;
|
|
|
|
+
|
|
|
|
+ /* Open /proc/pid/fd/ */
|
2008-10-06 17:17:04 +02:00
|
|
|
+ snprintf(path, sizeof(path), "/proc/%d/fd", pid);
|
2008-09-24 17:38:00 +02:00
|
|
|
+ if ((dir = opendir(path)) != NULL) {
|
|
|
|
+ /* Walk through the directory. */
|
|
|
|
+ while ((d = readdir(dir)) != NULL) {
|
2008-10-06 17:17:04 +02:00
|
|
|
+ if (*d->d_name == '.')
|
|
|
|
+ continue;
|
2008-09-24 17:38:00 +02:00
|
|
|
+ /* check for /dev/fuse */
|
2008-10-06 17:17:04 +02:00
|
|
|
+ snprintf(path, sizeof(path), "/proc/%d/fd/%s", pid, d->d_name);
|
2008-09-24 17:38:00 +02:00
|
|
|
+ if ((len = readlink(path, buf, sizeof(buf))) > 0) {
|
|
|
|
+ if (strncmp("/dev/fuse", buf, len) == 0) {
|
|
|
|
+ /* Fuse filesystem */
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ closedir(dir);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* Not a fuse filesystem */
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
PIDQ_HEAD *init_pid_q(PIDQ_HEAD *q)
|
|
|
|
{
|
|
|
|
q->head = q->next = q->tail = NULL;
|
2008-10-06 17:17:04 +02:00
|
|
|
@@ -779,11 +812,11 @@ int main(int argc, char **argv)
|
2008-09-24 17:38:00 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
- /* Now kill all processes except our session. */
|
2008-10-06 17:17:04 +02:00
|
|
|
+ /* Now kill all processes except init (pid 1), our session, and FUSE filesystems. */
|
2008-09-24 17:38:00 +02:00
|
|
|
sid = (int)getsid(0);
|
|
|
|
pid = (int)getpid();
|
|
|
|
for (p = plist; p; p = p->next) {
|
|
|
|
- if (p->pid == 1 || p->pid == pid || p->sid == sid || p->kernel) {
|
|
|
|
+ if (p->pid == 1 || p->pid == pid || p->sid == sid || p->kernel || is_fuse(p->pid)) {
|
|
|
|
kill(p->pid, SIGCONT);
|
|
|
|
continue;
|
|
|
|
}
|