diff --git a/src/kernel/pthread.cpp b/src/kernel/pthread.cpp index bdb125ab7..75dfdf9c2 100644 --- a/src/kernel/pthread.cpp +++ b/src/kernel/pthread.cpp @@ -3389,6 +3389,11 @@ int KYTY_SYSV_ABI PthreadCancel(Pthread thread) { return KERNEL_ERROR_EINVAL; } + // A joined thread's native handle is gone; the guest may still hold its handle. + if (thread->free) { + return KERNEL_ERROR_ESRCH; + } + int result = pthread_cancel(thread->p); LOGF("\tthread cancel: %s, %d\n", thread->name.c_str(), result); @@ -3492,10 +3497,8 @@ int KYTY_SYSV_ABI PthreadGetprio(Pthread thread, int* prio) { EXIT_NOT_IMPLEMENTED(prio == nullptr); - sched_param native_param {}; - int native_policy = 0; - if (pthread_getschedparam(thread->p, &native_policy, &native_param) != 0) { - return KERNEL_ERROR_EINVAL; + if (thread->free) { + return KERNEL_ERROR_ESRCH; } *prio = thread->attr->guest_priority; @@ -3510,6 +3513,11 @@ int KYTY_SYSV_ABI PthreadSetprio(Pthread thread, int prio) { return KERNEL_ERROR_ESRCH; } + // A joined thread's native handle is gone; the guest may still hold its handle. + if (thread->free) { + return KERNEL_ERROR_ESRCH; + } + sched_param param {}; int pol = 0;