This commit is contained in:
parent
89c55072f6
commit
5d24fd33c7
@ -6,6 +6,7 @@
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: boot.sysctl
|
||||
# Required-Start:
|
||||
# Should-Start: setserial boot.isapnp $local_fs
|
||||
# Required-Stop:
|
||||
# Default-Start: B
|
||||
|
@ -9,15 +9,22 @@
|
||||
if(unlikely(fd==-1)) return -1;
|
||||
num_read = read(fd, ret, cap - 1);
|
||||
close(fd);
|
||||
@@ -423,37 +423,41 @@ static int file2str(const char *director
|
||||
@@ -421,40 +421,58 @@ static int file2str(const char *director
|
||||
return num_read;
|
||||
}
|
||||
|
||||
+#define PROC_READ_MAY_EINTR 0 /* AFAIK reading /proc can catch EINTR
|
||||
+ * or ERESTARTSYS and therefore read
|
||||
+ * can be shorten before reaching EOF ?? */
|
||||
+
|
||||
static char** file2strvec(const char* directory, const char* what) {
|
||||
char buf[2048]; /* read buf bytes at a time */
|
||||
- char *p, *rbuf = 0, *endbuf, **q, **ret;
|
||||
- int fd, tot = 0, n, c, end_of_file = 0;
|
||||
- int align;
|
||||
+ char *p, *rbuf = (char*)0, *endbuf, **q, **ret;
|
||||
+ int fd, tot = 0, n, c;
|
||||
int align;
|
||||
+ int fd, c;
|
||||
+ ssize_t n, align, tot = 0;
|
||||
|
||||
sprintf(buf, "%s/%s", directory, what);
|
||||
- fd = open(buf, O_RDONLY, 0);
|
||||
@ -25,27 +32,28 @@
|
||||
if(fd==-1) return NULL;
|
||||
|
||||
/* read whole file into a memory buffer, allocating as we go */
|
||||
while ((n = read(fd, buf, sizeof buf - 1)) > 0) {
|
||||
- while ((n = read(fd, buf, sizeof buf - 1)) > 0) {
|
||||
- if (n < (int)(sizeof buf - 1))
|
||||
- end_of_file = 1;
|
||||
- if (n == 0 && rbuf == 0)
|
||||
- return NULL; /* process died between our open and read */
|
||||
+ do {
|
||||
+ n = read(fd, buf, sizeof(buf) - 1);
|
||||
if (n < 0) {
|
||||
- if (rbuf)
|
||||
- free(rbuf);
|
||||
- return NULL; /* read error */
|
||||
+#if defined(PROC_READ_MAY_EINTR) && (PROC_READ_MAY_EINTR > 0)
|
||||
+ if (errno == EINTR)
|
||||
+ continue;
|
||||
if (rbuf)
|
||||
free(rbuf);
|
||||
- return NULL; /* read error */
|
||||
+ return NULL; /* read error! */
|
||||
+#endif
|
||||
+ tot = 0;
|
||||
+ break; /* read error! */
|
||||
+ }
|
||||
+ if (n == 0) {
|
||||
+ if(rbuf == (char*)0)
|
||||
+ return NULL; /* process died between our open and read */
|
||||
+ tot = 0; /* process died between our open and read */
|
||||
+ break; /* we're done */
|
||||
+ }
|
||||
+ if (n < (int)(sizeof(buf) - 1)) {
|
||||
+ if (buf[n-1]) /* last read char not null */
|
||||
+ buf[n++] = '\0'; /* so append null-terminator */
|
||||
}
|
||||
- if (end_of_file && buf[n-1]) /* last read char not null */
|
||||
- buf[n++] = '\0'; /* so append null-terminator */
|
||||
@ -54,19 +62,33 @@
|
||||
tot += n; /* increment total byte ctr */
|
||||
- if (end_of_file)
|
||||
- break;
|
||||
}
|
||||
- }
|
||||
+#if defined(PROC_READ_MAY_EINTR) && (PROC_READ_MAY_EINTR > 0)
|
||||
+ } while (n > 0);
|
||||
+#else
|
||||
+ } while (n == (sizeof(buf) - 1));
|
||||
+#endif
|
||||
+
|
||||
close(fd);
|
||||
- if (n <= 0 && !end_of_file) {
|
||||
- if (rbuf) free(rbuf);
|
||||
- return NULL; /* read error */
|
||||
+
|
||||
+ if (tot == 0) {
|
||||
+ if (rbuf)
|
||||
+ free(rbuf);
|
||||
+ return NULL; /* read error? */
|
||||
}
|
||||
+
|
||||
+ if (rbuf[tot-1]) { /* last read char not null */
|
||||
+ rbuf = xrealloc(rbuf, tot + 1); /* allocate more memory */
|
||||
+ rbuf[tot++] = '\0'; /* and append null-terminator */
|
||||
+ }
|
||||
+
|
||||
endbuf = rbuf + tot; /* count space for pointers */
|
||||
align = (sizeof(char*)-1) - ((tot + sizeof(char*)-1) & (sizeof(char*)-1));
|
||||
@@ -482,7 +486,7 @@ int read_cmdline(char *restrict const ds
|
||||
for (c = 0, p = rbuf; p < endbuf; p++)
|
||||
@@ -482,7 +500,7 @@ int read_cmdline(char *restrict const ds
|
||||
unsigned n = 0;
|
||||
dst[0] = '\0';
|
||||
snprintf(name, sizeof name, "/proc/%u/cmdline", pid);
|
||||
|
@ -1,3 +1,13 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Jan 12 19:07:33 CET 2007 - werner@suse.de
|
||||
|
||||
- Add missing Required-Start to boot.sysctl [#231677]
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Aug 3 14:41:54 CEST 2006 - werner@suse.de
|
||||
|
||||
- Read upto EOF [#194598]
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jul 28 13:31:56 CEST 2006 - werner@suse.de
|
||||
|
||||
|
12
procps.spec
12
procps.spec
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package procps (Version 3.2.7)
|
||||
#
|
||||
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# This file and all modifications and additions to the pristine
|
||||
# package are under the same license as the package itself.
|
||||
#
|
||||
@ -12,12 +12,12 @@
|
||||
|
||||
Name: procps
|
||||
URL: http://procps.sf.net
|
||||
License: GPL, LGPL
|
||||
License: GNU General Public License (GPL), GNU Library General Public License v. 2.0 and 2.1 (LGPL)
|
||||
Group: System/Monitoring
|
||||
PreReq: %fillup_prereq %insserv_prereq
|
||||
Autoreqprov: on
|
||||
Version: 3.2.7
|
||||
Release: 3
|
||||
Release: 26
|
||||
Summary: ps utilities for /proc
|
||||
Provides: ps
|
||||
Obsoletes: ps
|
||||
@ -151,6 +151,10 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%_mandir/man8/sysctl.8.gz
|
||||
|
||||
%changelog -n procps
|
||||
* Fri Jan 12 2007 - werner@suse.de
|
||||
- Add missing Required-Start to boot.sysctl [#231677]
|
||||
* Thu Aug 03 2006 - werner@suse.de
|
||||
- Read upto EOF [#194598]
|
||||
* Fri Jul 28 2006 - werner@suse.de
|
||||
- Don't stop reading if the read buffer boundary is reached [#194598]
|
||||
* Fri Jul 28 2006 - olh@suse.de
|
||||
@ -400,7 +404,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
- port all required patches to 21.2
|
||||
* Tue Sep 10 2002 - adrian@suse.de
|
||||
- fix split alias
|
||||
-Obsoletes: ps:/usr/X11R6/bin/xcpustate
|
||||
-Obsoletes: ps:/usr/X11R6/bin/xcpustate
|
||||
+Provides: ps:/usr/X11R6/bin/xcpustate
|
||||
* Thu Aug 22 2002 - kukuk@suse.de
|
||||
- fix PreRequires.
|
||||
|
Loading…
x
Reference in New Issue
Block a user