6906587 top sometimes goes into infinite loop in getptable/hash_lookup_pidthr
authorM. Ajaykumar Venkatesulu <Ajaykumar.Venkatesulu@Sun.COM>
Sun, 03 Jul 2011 23:10:05 -0700
changeset 361 22214726d642
parent 360 4fd3779cba48
child 362 e1cadde52f4c
6906587 top sometimes goes into infinite loop in getptable/hash_lookup_pidthr
components/top/patches/03.sunos5.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/top/patches/03.sunos5.patch	Sun Jul 03 23:10:05 2011 -0700
@@ -0,0 +1,17 @@
+--- top-3.8beta1/machine/m_sunos5.c.orig	Fri Jun 17 05:40:25 2011
++++ top-3.8beta1/machine/m_sunos5.c	Fri Jun 17 05:48:17 2011
+@@ -2064,7 +2064,13 @@
+ 
+ 	    /* read the whole file */
+ 	    p = malloc(st.st_size);
+-	    (void)pread(fd, p, st.st_size, 0);
++	    if (pread(fd, p, st.st_size, 0) == -1)
++	    {
++		(void) close(fd);
++		op->fd_psinfo = -1;
++		free(p);
++		continue;
++	    }	
+ 
+ 	    /* cache the file descriptor if we can */
+ 	    if (fd < maxfiles)