-terminate_proc(int exit_code)
-{
- __current->state = PS_TERMNAT;
- __current->exit_code = exit_code;
+terminate_thread(struct thread* thread, ptr_t val) {
+ thread->exit_val = val;
+ thread->state = PS_TERMNAT;
+
+ struct proc_info* proc = thread->process;
+ if (proc->thread_count == 1) {
+ terminate_proc_only(thread->process, 0);
+ }
+}
+
+void
+terminate_current_thread(ptr_t val) {
+ terminate_thread(current_thread, val);
+}
+
+void
+terminate_proccess(struct proc_info* proc, int exit_code) {
+ assert(!kernel_process(proc));
+
+ if (proc->pid == 1) {
+ panick("Attempt to kill init");
+ }
+
+ terminate_proc_only(proc, exit_code);