diff --git a/sys/kern/handle.c b/sys/kern/handle.c index 49a2d82..cad6fa4 100644 --- a/sys/kern/handle.c +++ b/sys/kern/handle.c @@ -33,12 +33,12 @@ void Handle_Destroy(Process *proc) { int i; - Handle *handle; + Handle *handle, *handle_tmp; for (i = 0; i < PROCESS_HANDLE_SLOTS; i++) { - TAILQ_FOREACH(handle, &proc->handles[i], handleList) { - (handle->close)(handle); + TAILQ_FOREACH_SAFE(handle, &proc->handles[i], handleList, handle_tmp) { TAILQ_REMOVE(&proc->handles[i], handle, handleList); + (handle->close)(handle); } } }