sysvinit/sysvinit-2.88dsf-no-kill.patch

69 lines
1.6 KiB
Diff

--- src/killall5.c
+++ src/killall5.c 2011-10-17 12:11:32.000000000 +0000
@@ -454,6 +454,38 @@ int readarg(FILE *fp, char *buf, int sz)
}
/*
+ * Scan the filedescriptors of pid for /dev/fuse
+ */
+int is_fuse(const char *pid) {
+ DIR *dir;
+ char path[256];
+ char buf[256];
+ struct dirent *d;
+ ssize_t len;
+
+ /* Open /proc/pid/fd/ */
+ snprintf(path, sizeof(path), "/proc/%s/fd", pid);
+ if ((dir = opendir(path)) != NULL) {
+ int dfd = dirfd(dir);
+ /* Walk through the directory. */
+ while ((d = readdir(dir)) != NULL) {
+ if (*d->d_name == '.')
+ continue;
+ /* check for /dev/fuse */
+ if ((len = readlinkat(dfd, d->d_name, buf, sizeof(buf))) > 0) {
+ buf[len] = '\0';
+ if (strcmp("/dev/fuse", buf) == 0)
+ return 1; /* Fuse filesystem */
+ }
+ }
+ closedir(dir);
+ }
+
+ /* Not a fuse filesystem */
+ return 0;
+}
+
+/*
* Read the proc filesystem.
* CWD must be /proc to avoid problems if / is affected by the killing (ie depend on fuse).
*/
@@ -634,6 +666,26 @@ int readproc(int do_stat)
p->nfs = 0;
switch (do_stat) {
+ case NO_STAT:
+ if ((len = readlink(path, buf, PATH_MAX)) < 0)
+ break;
+ buf[len] = '\0';
+
+ /* Check for uevent handler, mdmon, and for providers
+ of FUSE filesystems */
+ if ((strncmp(buf, "/sbin/udevd", 11) == 0) ||
+ (strncmp(buf, "/sbin/mdmon", 11) == 0) ||
+ (is_fuse(d->d_name))) {
+ OMIT *restrict optr;
+
+ xmemalign((void*)&optr, sizeof(void*), alignof(OMIT));
+ optr->next = omit;
+ optr->prev = (OMIT*)0;
+ optr->pid = pid;
+ omit = optr;
+ }
+
+ break;
case DO_NETFS:
if ((p->nfs = check4nfs(path, buf)))
goto link;