summaryrefslogtreecommitdiff
path: root/src/exit
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014-05-29 16:35:09 -0400
committerRich Felker <dalias@aerifal.cx>2014-05-29 16:35:09 -0400
commit2e55da911896a91e95b24ab5dc8a9d9b0718f4de (patch)
tree4a43f5d7b6b3f68d4e7a3df42e819643a0a50b11 /src/exit
parentd677d3fe830899926072af6dfffefb16ab6b50bd (diff)
downloadmusl-2e55da911896a91e95b24ab5dc8a9d9b0718f4de.tar.gz
musl-2e55da911896a91e95b24ab5dc8a9d9b0718f4de.tar.bz2
musl-2e55da911896a91e95b24ab5dc8a9d9b0718f4de.tar.xz
musl-2e55da911896a91e95b24ab5dc8a9d9b0718f4de.zip
remove useless synchronization in exit and quick_exit
calling exit more than once invokes undefined behavior. in some cases it's desirable to detect undefined behavior and diagnose it via a predictable crash, but the code here was silently covering up an uncommon case (exit from more than one thread) and turning a much more common case (recursive calls to exit) into a permanent hang.
Diffstat (limited to 'src/exit')
-rw-r--r--src/exit/exit.c7
-rw-r--r--src/exit/quick_exit.c4
2 files changed, 0 insertions, 11 deletions
diff --git a/src/exit/exit.c b/src/exit/exit.c
index 353f50b7..695bdc05 100644
--- a/src/exit/exit.c
+++ b/src/exit/exit.c
@@ -1,8 +1,6 @@
#include <stdlib.h>
#include <stdint.h>
#include "libc.h"
-#include "atomic.h"
-#include "syscall.h"
static void dummy()
{
@@ -21,11 +19,6 @@ extern void (*const __fini_array_end)() __attribute__((weak));
_Noreturn void exit(int code)
{
- static int lock;
-
- /* If more than one thread calls exit, hang until _Exit ends it all */
- while (a_swap(&lock, 1)) __syscall(SYS_pause);
-
__funcs_on_exit();
#ifndef SHARED
diff --git a/src/exit/quick_exit.c b/src/exit/quick_exit.c
index 1175d80c..ada91348 100644
--- a/src/exit/quick_exit.c
+++ b/src/exit/quick_exit.c
@@ -1,6 +1,4 @@
#include <stdlib.h>
-#include "syscall.h"
-#include "atomic.h"
#include "libc.h"
static void dummy() { }
@@ -8,8 +6,6 @@ weak_alias(dummy, __funcs_on_quick_exit);
_Noreturn void quick_exit(int code)
{
- static int lock;
- while (a_swap(&lock, 1)) __syscall(SYS_pause);
__funcs_on_quick_exit();
_Exit(code);
}