Sophie

Sophie

distrib > Mandriva > 2007.1 > i586 > media > main-updates-src > by-pkgid > 560a66f8a53021b4b9b753c8581c58a8 > files > 2

mozilla-firefox-2.0.0.13-1.1mdv2007.1.src.rpm

Index: unix_rand.c
===================================================================
RCS file: /cvsroot/mozilla/security/nss/lib/freebl/unix_rand.c,v
retrieving revision 1.23
diff -u -r1.23 unix_rand.c
--- unix_rand.c	6 Jan 2007 01:18:24 -0000	1.23
+++ unix_rand.c	6 Jan 2007 01:32:01 -0000
@@ -46,6 +46,7 @@
 #include "secrng.h"
 #include "secerr.h"
 #include "prerror.h"
+#include "prthread.h"
 
 size_t RNG_FileUpdate(const char *fileName, size_t limit);
 
@@ -845,25 +846,28 @@
 safe_pclose(FILE *fp)
 {
     pid_t pid;
-    int count, status;
+    int status = -1, rv;
 
     if ((pid = safe_popen_pid) == 0)
 	return -1;
     safe_popen_pid = 0;
 
+    fclose(fp);
+
+    /* yield the processor so the child gets some time to exit normally */
+    PR_Sleep(PR_INTERVAL_NO_WAIT);
+
     /* if the child hasn't exited, kill it -- we're done with its output */
-    count = 0;
-    while (waitpid(pid, &status, WNOHANG) == 0) {
-    	if (kill(pid, SIGKILL) < 0 && errno == ESRCH)
-	    break;
-	if (++count == 1000)
-	    break;
+    while ((rv = waitpid(pid, &status, WNOHANG)) == -1 && errno == EINTR)
+	;
+    if (rv == 0 && kill(pid, SIGKILL) == 0) {
+	while ((rv = waitpid(pid, &status, 0)) == -1 && errno == EINTR)
+	    ;
     }
 
     /* Reset SIGCHLD signal hander before returning */
     sigaction(SIGCHLD, &oldact, NULL);
 
-    fclose(fp);
     return status;
 }