mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
scheduler: hold reference on sched_getprocfrompid
This commit is contained in:
@@ -38,9 +38,14 @@ static pid_t currpid = 1;
|
||||
|
||||
proc_t *sched_getprocfrompid(int pid) {
|
||||
MUTEX_ACQUIRE(&sched_pidtablemutex, false);
|
||||
void *proc = NULL;
|
||||
hashtable_get(&pidtable, &proc, &pid, sizeof(pid));
|
||||
void *_proc = NULL;
|
||||
hashtable_get(&pidtable, &_proc, &pid, sizeof(pid));
|
||||
proc_t *proc = _proc;
|
||||
if (proc) {
|
||||
PROC_HOLD(proc);
|
||||
}
|
||||
MUTEX_RELEASE(&sched_pidtablemutex);
|
||||
|
||||
return proc;
|
||||
}
|
||||
|
||||
@@ -321,6 +326,8 @@ void sched_inactiveproc(proc_t *proc) {
|
||||
|
||||
hashtable_remove(&pidtable, &proc->pid, sizeof(proc->pid));
|
||||
|
||||
//arch_e9_puts("\n\ndestroy proc\n\n");
|
||||
//printf("destroy proc\n");
|
||||
sched_destroyproc(proc);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ syscallret_t syscall_kill(context_t *context, int pid, int signal) {
|
||||
else
|
||||
ret.errno = jobctl_signal(target, signal);
|
||||
|
||||
if (target) {
|
||||
PROC_RELEASE(target);
|
||||
}
|
||||
|
||||
ret.errno = 0;
|
||||
ret.ret = 0;
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user