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

This commit is contained in:
shadowbeat070
2026-10-20 15:54:14 +02:00
committed by nmzik
parent 6ad393775f
commit 7b7f9a70c6
+12 -4
View File
@@ -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;