mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 08:48:29 +00:00
Make more fixes and improvements
- Remove PAGESIZE constant - Fix realloc() documentation - Fix ttyname_r() error reporting - Make forking more reliable on Windows - Make execvp() a few microseconds faster - Make system() a few microseconds faster - Tighten up the socket-related magic numbers - Loosen restrictions on mmap() offset alignment - Improve GetProgramExecutableName() with getenv("_") - Use mkstemp() as basis for mktemp(), tmpfile(), tmpfd() - Fix flakes in pthread_cancel_test, unix_test, fork_test - Fix recently introduced futex stack overflow regression - Let sockets be passed as stdio to subprocesses on Windows - Improve security of bind() on Windows w/ SO_EXCLUSIVEADDRUSE
This commit is contained in:
parent
140a8a52e5
commit
18bb5888e1
311 changed files with 1239 additions and 2622 deletions
|
@ -54,9 +54,11 @@ int _pthread_cancel_sys(void) {
|
|||
|
||||
static void OnSigThr(int sig, siginfo_t *si, void *ctx) {
|
||||
ucontext_t *uc = ctx;
|
||||
struct CosmoTib *t = __get_tls();
|
||||
struct PosixThread *pt = (struct PosixThread *)t->tib_pthread;
|
||||
if (pt && !(pt->flags & PT_NOCANCEL) &&
|
||||
struct CosmoTib *t;
|
||||
struct PosixThread *pt;
|
||||
if ((t = __get_tls()) && // TODO: why can it be null on freebsd?
|
||||
(pt = (struct PosixThread *)t->tib_pthread) &&
|
||||
!(pt->flags & PT_NOCANCEL) &&
|
||||
atomic_load_explicit(&pt->cancelled, memory_order_acquire)) {
|
||||
sigaddset(&uc->uc_sigmask, sig);
|
||||
if (systemfive_cancellable <= (char *)uc->uc_mcontext.rip &&
|
||||
|
@ -255,14 +257,21 @@ static void ListenForSigThr(void) {
|
|||
* while running read(). Masked mode doesn't have second chances. You
|
||||
* must rigorously check the results of each cancellation point call.
|
||||
*
|
||||
* Unit tests should be able to safely ignore the return value, or at
|
||||
* the very least be programmed to consider ESRCH a successful status
|
||||
*
|
||||
* @return 0 on success, or errno on error
|
||||
* @raise ESRCH if thread isn't alive
|
||||
* @raise ESRCH if system thread wasn't alive or we lost a race
|
||||
*/
|
||||
errno_t pthread_cancel(pthread_t thread) {
|
||||
int e, rc, tid;
|
||||
static bool once;
|
||||
struct PosixThread *pt;
|
||||
if (!once) ListenForSigThr(), once = true;
|
||||
__require_tls();
|
||||
if (!once) {
|
||||
ListenForSigThr();
|
||||
once = true;
|
||||
}
|
||||
pt = (struct PosixThread *)thread;
|
||||
switch (atomic_load_explicit(&pt->status, memory_order_acquire)) {
|
||||
case kPosixThreadZombie:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue