kernel: answer ESRCH for a thread the detached-thread reaper has joined

This commit is contained in:
shadowbeat070 authored and nmzik committed 2026-10-20 15:54:14 +02:00
1 parent 6ad393775f
commit 7b7f9a70c6
1 file changed
+12 -4
+12 -4
View File
@@ -3389,6 +3389,11 @@ int KYTY_SYSV_ABI PthreadCancel(Pthread thread) {
return KERNEL_ERROR_EINVAL; 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); int result = pthread_cancel(thread->p);
LOGF("\tthread cancel: %s, %d\n", thread->name.c_str(), result); 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); EXIT_NOT_IMPLEMENTED(prio == nullptr);
sched_param native_param {}; if (thread->free) {
int native_policy = 0; return KERNEL_ERROR_ESRCH;
if (pthread_getschedparam(thread->p, &native_policy, &native_param) != 0) {
return KERNEL_ERROR_EINVAL;
} }
*prio = thread->attr->guest_priority; *prio = thread->attr->guest_priority;
@@ -3510,6 +3513,11 @@ int KYTY_SYSV_ABI PthreadSetprio(Pthread thread, int prio) {
return KERNEL_ERROR_ESRCH; 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 {}; sched_param param {};
int pol = 0; int pol = 0;