diff options
| author | rsc <devnull@localhost> | 2005-07-27 20:25:34 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2005-07-27 20:25:34 +0000 |
| commit | 9689b580bdb168b87a20a5e466864337d591acfa (patch) | |
| tree | 973ea1fb43cf9559b4a0a98b7e08d718e1fff876 /src/libthread/Linux.c | |
| parent | 5f4529e351e77e4ab61d258ca3dea69852a1e0ba (diff) | |
Try to avoid races in underlying C library
during threadexitsall.
Diffstat (limited to 'src/libthread/Linux.c')
| -rw-r--r-- | src/libthread/Linux.c | 14 |
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(); |