This commit is contained in:
parent
ec091fc303
commit
86198d1ced
@ -1,60 +1,11 @@
|
||||
--- src/killall5.c
|
||||
+++ src/killall5.c
|
||||
@@ -284,6 +284,7 @@
|
||||
|
||||
/*
|
||||
* Read the proc filesystem.
|
||||
+ * CWD must be /proc.
|
||||
*/
|
||||
int readproc()
|
||||
{
|
||||
@@ -299,7 +300,7 @@
|
||||
int pid, f;
|
||||
|
||||
/* Open the /proc directory. */
|
||||
- if ((dir = opendir("/proc")) == NULL) {
|
||||
+ if ((dir = opendir(".")) == NULL) {
|
||||
nsyslog(LOG_ERR, "cannot opendir(/proc)");
|
||||
return -1;
|
||||
}
|
||||
@@ -326,10 +327,10 @@
|
||||
memset(p, 0, sizeof(PROC));
|
||||
|
||||
/* Open the status file. */
|
||||
- snprintf(path, sizeof(path), "/proc/%s/stat", d->d_name);
|
||||
+ snprintf(path, sizeof(path), "%s/stat", d->d_name);
|
||||
|
||||
/* Read SID & statname from it. */
|
||||
- if ((fp = fopen(path, "r")) != NULL) {
|
||||
+ if ((fp = fopen(path, "r")) != NULL) {
|
||||
buf[0] = 0;
|
||||
fgets(buf, sizeof(buf), fp);
|
||||
|
||||
@@ -343,7 +344,7 @@
|
||||
if (q == NULL) {
|
||||
p->sid = 0;
|
||||
nsyslog(LOG_ERR,
|
||||
- "can't get program name from %s\n",
|
||||
+ "can't get program name from /proc/%s\n",
|
||||
path);
|
||||
if (p->argv0) free(p->argv0);
|
||||
if (p->argv1) free(p->argv1);
|
||||
@@ -389,7 +390,7 @@
|
||||
continue;
|
||||
}
|
||||
|
||||
- snprintf(path, sizeof(path), "/proc/%s/cmdline", d->d_name);
|
||||
+ snprintf(path, sizeof(path), "%s/cmdline", d->d_name);
|
||||
if ((fp = fopen(path, "r")) != NULL) {
|
||||
|
||||
/* Now read argv[0] */
|
||||
@@ -456,6 +457,39 @@
|
||||
+++ 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
|
||||
+ * CWD must be /proc.
|
||||
+ */
|
||||
+int is_fuse(int pid) {
|
||||
+ DIR *dir;
|
||||
@ -64,13 +15,14 @@
|
||||
+ ssize_t len;
|
||||
+
|
||||
+ /* Open /proc/pid/fd/ */
|
||||
+ snprintf(path, sizeof(path), "%d/fd", pid);
|
||||
+ 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), "%d/fd/%s",
|
||||
+ pid, d->d_name);
|
||||
+ 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 */
|
||||
@ -88,37 +40,12 @@
|
||||
PIDQ_HEAD *init_pid_q(PIDQ_HEAD *q)
|
||||
{
|
||||
q->head = q->next = q->tail = NULL;
|
||||
@@ -688,6 +722,11 @@
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
+ if (chdir("/proc") == -1) {
|
||||
+ nsyslog(LOG_ERR, "chdir /proc failed");
|
||||
+ return(1);
|
||||
+ }
|
||||
+
|
||||
/* Print out process-ID's one by one. */
|
||||
readproc();
|
||||
for(f = 0; f < argc; f++) {
|
||||
@@ -759,6 +798,11 @@
|
||||
/* Which NFS partitions are online? */
|
||||
init_nfs();
|
||||
|
||||
+ if (chdir("/proc") == -1) {
|
||||
+ nsyslog(LOG_ERR, "chdir /proc failed");
|
||||
+ return(1);
|
||||
+ }
|
||||
+
|
||||
/*
|
||||
* Ignoring SIGKILL and SIGSTOP do not make sense, but
|
||||
* someday kill(-1, sig) might kill ourself if we don't
|
||||
@@ -779,11 +823,12 @@
|
||||
@@ -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. */
|
||||
+ /* 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) {
|
||||
|
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Oct 1 18:08:36 CEST 2008 - werner@suse.de
|
||||
|
||||
- Minimize fuse patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Oct 1 17:43:52 CEST 2008 - ro@suse.de
|
||||
|
||||
|
@ -30,7 +30,7 @@ Group: System/Base
|
||||
PreReq: coreutils
|
||||
AutoReqProv: on
|
||||
Version: 2.86
|
||||
Release: 184
|
||||
Release: 185
|
||||
Summary: SysV-Style init
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildRequires: libselinux-devel libsepol-devel
|
||||
@ -317,6 +317,8 @@ rm -rf ${RPM_BUILD_ROOT}
|
||||
%doc %{_mandir}/man8/startpar.8.gz
|
||||
|
||||
%changelog
|
||||
* Wed Oct 01 2008 werner@suse.de
|
||||
- Minimize fuse patch
|
||||
* Wed Oct 01 2008 ro@suse.de
|
||||
- fix fuse_kill patch so that it does not break pidof
|
||||
* Wed Oct 01 2008 werner@suse.de
|
||||
|
Loading…
x
Reference in New Issue
Block a user