sysvinit/killproc-2.16.dif
Dr. Werner Fink 782e8a1416 Accepting request 23608 from home:michal-m:branches:Base:System
Copy from home:michal-m:branches:Base:System/sysvinit via accept of submit request 23608 revision 3.
Request was accepted with message:
reviewed ok.

OBS-URL: https://build.opensuse.org/request/show/23608
OBS-URL: https://build.opensuse.org/package/show/Base:System/sysvinit?expand=0&rev=13
2009-11-02 16:28:31 +00:00

155 lines
3.8 KiB
Plaintext

--- .dummy
+++ .dummy 2009-08-19 12:18:39.181901099 +0200
@@ -0,0 +1 @@
+this is a dummy, remove if real changes are required
--- libinit.c
+++ libinit.c 2009-10-28 10:47:13.711429753 +0100
@@ -320,13 +320,15 @@ static ssize_t xread(int fd, void *inbuf
while (1) {
errno = 0;
bytes = read(fd, inbuf, count);
- if (bytes < 0 && (errno == EINTR || errno == EAGAIN))
- continue;
- if (bytes < 0)
+ if (bytes < 0) {
+ if (errno == EINTR || errno == EAGAIN)
+ continue;
+ if (errno == ESRCH)
+ goto out;
break;
+ }
goto out;
}
-
warn("xread error: %s\n", strerror(errno));
out:
errno = olderr;
@@ -446,9 +448,9 @@ static pid_t getpppid(const pid_t ppid)
goto out;
if ((fp = open(proc(pid, "stat"), O_PROCMODE)) != -1) {
- xread(fp, buf, BUFSIZ);
+ ssize_t len = xread(fp, buf, BUFSIZ);
close(fp);
- if (sscanf(buf,"%*d %*s %*c %d %*d %*d", &pppid) != 1)
+ if (len <= 0 || sscanf(buf,"%*d %*s %*c %d %*d %*d", &pppid) != 1)
warn("can not read ppid for process %d!\n", ppid);
}
out:
@@ -591,10 +593,11 @@ int pidof (const char * inname, const ch
char ent[3];
boolean thread;
ssize_t len;
+
len = xread(fp,ent,3);
close(fp);
- if (!len)
+ if (len <= 0)
continue;
thread = (strncmp(ent, "0 ", 2) == 0);
@@ -682,6 +685,9 @@ int pidof (const char * inname, const ch
len = xread(fp, entry, PATH_MAX);
close(fp);
+ if (len <= 0)
+ continue;
+
/* Seek for a script not for a binary */
if (!(scrpt = checkscripts(entry, root, len, d->d_name)))
continue;
@@ -713,7 +719,7 @@ int pidof (const char * inname, const ch
len = xread(fp, entry, PATH_MAX);
close(fp);
- if (!len)
+ if (len <= 0)
continue;
comm = index(entry, ' ');
@@ -764,7 +770,8 @@ int verify_pidfile (const char * pid_fil
const char * root, unsigned short flags,
const boolean ignore)
{
- int fp, cnt;
+ int fp;
+ ssize_t cnt;
boolean isscrpt = false;
pid_t pid;
char *swapname = NULL, *bufp;
@@ -789,11 +796,12 @@ int verify_pidfile (const char * pid_fil
}
errno = 0;
- if ((cnt = xread (fp, buf, BUFSIZ)) < 0) {
+ cnt = xread(fp, buf, BUFSIZ);
+ close(fp);
+ if (cnt < 0) {
warn("Can not read pid file %s: %s\n", pid_file, strerror(errno));
return -1;
}
- close(fp);
buf[cnt] = '\0';
bufp = buf;
@@ -847,10 +855,11 @@ int verify_pidfile (const char * pid_fil
char ent[3];
boolean thread;
ssize_t len;
+
len = xread(fp, ent, sizeof(ent));
close(fp);
- if (!len)
+ if (len <= 0)
goto out;
thread = (strncmp(ent, "0 ", 2) == 0);
@@ -932,6 +941,9 @@ int verify_pidfile (const char * pid_fil
len = xread(fp, entry, PATH_MAX);
close(fp);
+ if (len <= 0)
+ goto out;
+
/* Seek for a script not for a binary */
if (!(scrpt = checkscripts(entry, root, len, buf)))
goto out; /* Nothing found */
@@ -951,7 +963,7 @@ int verify_pidfile (const char * pid_fil
len = xread(fp, entry, PATH_MAX);
close(fp);
- if (!len)
+ if (len <= 0)
goto out;
comm = index(entry, ' ');
@@ -1040,7 +1052,7 @@ int check_pids (const char * inname, con
len = xread(fp, ent, sizeof(ent));
close(fp);
- if (!len)
+ if (len <= 0)
goto ignore; /* Bogus */
thread = (strncmp(ent, "0 ", 2) == 0);
@@ -1111,7 +1123,7 @@ int check_pids (const char * inname, con
len = xread(fp, entry, PATH_MAX);
close(fp);
- if (!len)
+ if (len <= 0)
goto ignore; /* Bogus */
/* Seek for a script not for a binary */
@@ -1131,7 +1143,7 @@ int check_pids (const char * inname, con
len = xread(fp, entry, PATH_MAX);
close(fp);
- if (!len)
+ if (len <= 0)
goto ignore; /* Bogus */
comm = index(entry, ' ');