summaryrefslogtreecommitdiff
path: root/src/kernel/proc.c
diff options
context:
space:
mode:
authordzwdz2021-09-04 18:17:35 +0200
committerdzwdz2021-09-04 18:17:35 +0200
commitc4531fa5e1aa16b7ba74de2975eadf06b3052b78 (patch)
tree7538d728e7828bc3661052c6a181d8f365fc3df7 /src/kernel/proc.c
parent400f218cdad6bceaed9843d4d44ab66593da591a (diff)
refactor finding empty handles to a function
Diffstat (limited to 'src/kernel/proc.c')
-rw-r--r--src/kernel/proc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/kernel/proc.c b/src/kernel/proc.c
index 19b09a8..e504a5d 100644
--- a/src/kernel/proc.c
+++ b/src/kernel/proc.c
@@ -90,3 +90,13 @@ struct process *_process_find_recursive(
struct process *process_find(enum process_state target) {
return _process_find_recursive(target, process_first);
}
+
+handle_t process_find_handle(struct process *proc) {
+ handle_t handle;
+ for (handle = 0; handle < HANDLE_MAX; handle++) {
+ if (proc->handles[handle].type == HANDLE_EMPTY)
+ break;
+ }
+ if (handle == HANDLE_MAX) handle = -1;
+ return handle;
+}