Fix a deadlock seen in thunderbird w/engimail caused by safe_pclose()

returning without waiting for the child process to complete which causes
a deadlock between nspr's WaitPidDaemonThread() and PR_WaitProcess().
Reported upstream w/more details:
https://bugzilla.mozilla.org/show_bug.cgi?id=385465
okay martynas@
This commit is contained in:
kurt 2007-06-22 13:37:58 +00:00
parent cbb6a6bf82
commit 2586dcb948
2 changed files with 35 additions and 1 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.5 2007/03/26 20:45:44 martynas Exp $ # $OpenBSD: Makefile,v 1.6 2007/06/22 13:37:58 kurt Exp $
SHARED_ONLY= Yes SHARED_ONLY= Yes
@ -6,6 +6,7 @@ COMMENT= "libraries to support development of security-enabled apps"
VERSION= 3.11.5 VERSION= 3.11.5
DISTNAME= nss-${VERSION} DISTNAME= nss-${VERSION}
PKGNAME= ${DISTNAME}p0
SO_VERSION= 19.0 SO_VERSION= 19.0
.for _lib in freebl3 nss3 nssckbi smime3 softokn3 ssl3 .for _lib in freebl3 nss3 nssckbi smime3 softokn3 ssl3
SHARED_LIBS+= ${_lib} ${SO_VERSION} SHARED_LIBS+= ${_lib} ${SO_VERSION}

View File

@ -0,0 +1,33 @@
$OpenBSD: patch-mozilla_security_nss_lib_freebl_unix_rand_c,v 1.1 2007/06/22 13:37:58 kurt Exp $
--- mozilla/security/nss/lib/freebl/unix_rand.c.orig Thu Jun 21 14:25:55 2007
+++ mozilla/security/nss/lib/freebl/unix_rand.c Thu Jun 21 14:41:25 2007
@@ -843,21 +843,19 @@ safe_popen(char *cmd)
static int
safe_pclose(FILE *fp)
{
- pid_t pid;
- int count, status;
+ pid_t pid, ret;
+ int status;
if ((pid = safe_popen_pid) == 0)
return -1;
safe_popen_pid = 0;
- /* 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;
- }
+ /* kill the child in case it hasn't exited -- we're done with its output */
+ kill(pid, SIGKILL);
+
+ do {
+ ret = waitpid(pid, &status, 0);
+ } while (ret == (pid_t) -1 && errno == EINTR);
/* Reset SIGCHLD signal hander before returning */
sigaction(SIGCHLD, &oldact, NULL);