aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/Linux.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-07-27 20:25:34 +0000
committerrsc <devnull@localhost>2005-07-27 20:25:34 +0000
commit9689b580bdb168b87a20a5e466864337d591acfa (patch)
tree973ea1fb43cf9559b4a0a98b7e08d718e1fff876 /src/libthread/Linux.c
parent5f4529e351e77e4ab61d258ca3dea69852a1e0ba (diff)
Try to avoid races in underlying C library
during threadexitsall.
Diffstat (limited to 'src/libthread/Linux.c')
-rw-r--r--src/libthread/Linux.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libthread/Linux.c b/src/libthread/Linux.c
index f741a03d..14698856 100644
--- a/src/libthread/Linux.c
+++ b/src/libthread/Linux.c
@@ -311,6 +311,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();