提交 2e55da91 编写于 作者: R Rich Felker

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.
上级 d677d3fe
#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
......
#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);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册