2009-12-04 15:15:20 +01:00
|
|
|
--- .dummy
|
2009-12-07 15:53:17 +01:00
|
|
|
+++ .dummy 2009-08-19 12:18:39.181901099 +0200
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+this is a dummy, remove if real changes are required
|
2009-10-03 02:29:19 +02:00
|
|
|
--- libinit.c
|
2009-12-07 15:53:17 +01:00
|
|
|
+++ libinit.c 2009-10-28 10:47:13.711429753 +0100
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -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)
|
2009-10-03 02:29:19 +02:00
|
|
|
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:
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -591,10 +593,11 @@ int pidof (const char * inname, const ch
|
2009-10-03 02:29:19 +02:00
|
|
|
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);
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -682,6 +685,9 @@ int pidof (const char * inname, const ch
|
2009-10-03 02:29:19 +02:00
|
|
|
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;
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -713,7 +719,7 @@ int pidof (const char * inname, const ch
|
2009-10-03 02:29:19 +02:00
|
|
|
len = xread(fp, entry, PATH_MAX);
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
- if (!len)
|
|
|
|
+ if (len <= 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
comm = index(entry, ' ');
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -764,7 +770,8 @@ int verify_pidfile (const char * pid_fil
|
2009-10-03 02:29:19 +02:00
|
|
|
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;
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -789,11 +796,12 @@ int verify_pidfile (const char * pid_fil
|
2009-10-03 02:29:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -847,10 +855,11 @@ int verify_pidfile (const char * pid_fil
|
2009-10-03 02:29:19 +02:00
|
|
|
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);
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -932,6 +941,9 @@ int verify_pidfile (const char * pid_fil
|
2009-10-03 02:29:19 +02:00
|
|
|
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 */
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -951,7 +963,7 @@ int verify_pidfile (const char * pid_fil
|
2009-10-03 02:29:19 +02:00
|
|
|
len = xread(fp, entry, PATH_MAX);
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
- if (!len)
|
|
|
|
+ if (len <= 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
comm = index(entry, ' ');
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -1040,7 +1052,7 @@ int check_pids (const char * inname, con
|
2009-10-03 02:29:19 +02:00
|
|
|
len = xread(fp, ent, sizeof(ent));
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
- if (!len)
|
|
|
|
+ if (len <= 0)
|
|
|
|
goto ignore; /* Bogus */
|
|
|
|
|
|
|
|
thread = (strncmp(ent, "0 ", 2) == 0);
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -1111,7 +1123,7 @@ int check_pids (const char * inname, con
|
2009-10-03 02:29:19 +02:00
|
|
|
len = xread(fp, entry, PATH_MAX);
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
- if (!len)
|
|
|
|
+ if (len <= 0)
|
|
|
|
goto ignore; /* Bogus */
|
|
|
|
|
|
|
|
/* Seek for a script not for a binary */
|
2009-12-04 15:15:20 +01:00
|
|
|
@@ -1131,7 +1143,7 @@ int check_pids (const char * inname, con
|
2009-10-03 02:29:19 +02:00
|
|
|
len = xread(fp, entry, PATH_MAX);
|
|
|
|
close(fp);
|
|
|
|
|
|
|
|
- if (!len)
|
|
|
|
+ if (len <= 0)
|
|
|
|
goto ignore; /* Bogus */
|
|
|
|
|
|
|
|
comm = index(entry, ' ');
|