sysvinit/sysvinit-2.86-fuse-no-kill.patch

57 lines
1.4 KiB
Diff
Raw Normal View History

--- src/killall5.c
+++ src/killall5.c 2008-10-01 18:05:29.829808878 +0200
@@ -456,6 +456,39 @@ int readproc()
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/ */
+ snprintf(path, sizeof(path), "/proc/%d/fd", pid);
+ if ((dir = opendir(path)) != NULL) {
+ /* Walk through the directory. */
+ while ((d = readdir(dir)) != NULL) {
+ if (*d->d_name == '.')
+ continue;
+ /* check for /dev/fuse */
+ snprintf(path, sizeof(path), "/proc/%d/fd/%s", pid, d->d_name);
+ 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;
@@ -779,11 +812,11 @@ int main(int argc, char **argv)
exit(1);
}
- /* Now kill all processes except our session. */
+ /* Now kill all processes except init (pid 1), our session, and FUSE filesystems. */
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;
}