+__DEFINE_LXSYSCALL1(pid_t, wait, int*, status) {
+ pid_t cur = __current->pid;
+ struct proc_info *proc, *n;
+ if (llist_empty(&__current->children)) {
+ return -1;
+ }
+repeat:
+ llist_for_each(proc, n, &__current->children, siblings) {
+ if (proc->state == PROC_TERMNAT) {
+ goto done;
+ }
+ }
+ // FIXME: 除了循环,也许有更高效的办法…… (在这里进行schedule,需要重写context switch!)
+ goto repeat;
+
+done:
+ *status = proc->exit_code;
+ return destroy_process(proc->pid);
+}
+