aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/BSD.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libthread/BSD.c')
-rw-r--r--src/libthread/BSD.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libthread/BSD.c b/src/libthread/BSD.c
index 0bc19057..8090ea59 100644
--- a/src/libthread/BSD.c
+++ b/src/libthread/BSD.c
@@ -285,6 +285,20 @@ threadexitsall(char *msg)
int i, npid, mypid;
Proc *p;
+ /*
+ * Only one guy, ever, gets to run this.
+ * If two guys do it, inevitably they end up
+ * tripping over each other in the underlying
+ * C library exit() implementation, which is
+ * trying to run the atexit handlers and apparently
+ * not thread safe. This has been observed on
+ * both Linux and OpenBSD. Sigh.
+ */
+ {
+ static Lock onelock;
+ lock(&onelock);
+ }
+
if(msg == nil)
msg = "";
mypid = getpid();