Support pid of zero when calling waitpid

Make waitpid wait any process with the same pgid of the caller when
setting zero to the pid argument.
This commit is contained in:
Masamichi Takagi
2014-09-08 22:40:56 +09:00
parent ac40b96c24
commit b50e205a61
3 changed files with 9 additions and 1 deletions

View File

@ -183,6 +183,11 @@ do_setpgid(int pid, int pgid)
continue;
if(p->pid == pid){
p->pgid = pgid;
/* Update pgid in fork_tree because it's used in wait4 */
ihk_mc_spinlock_lock_noirq(&p->ftn->lock);
p->ftn->pgid = pgid;
ihk_mc_spinlock_unlock_noirq(&p->ftn->lock);
}
}
ihk_mc_spinlock_unlock(&(v->runq_lock), irqstate);

View File

@ -144,6 +144,7 @@ struct fork_tree_node {
struct process *owner;
int pid;
int pgid;
struct fork_tree_node *parent;
struct list_head children;

View File

@ -305,6 +305,7 @@ SYSCALL_DECLARE(wait4)
struct process *proc = cpu_local_var(current);
struct fork_tree_node *child, *child_iter;
int pid = (int)ihk_mc_syscall_arg0(ctx);
int pgid = proc->pgid;
int *status = (int *)ihk_mc_syscall_arg1(ctx);
int options = (int)ihk_mc_syscall_arg2(ctx);
int ret;
@ -326,7 +327,7 @@ rescan:
ihk_mc_spinlock_lock_noirq(&child_iter->lock);
if (pid == -1 || pid == child_iter->pid) {
if (pid == -1 || (pid == 0 && pgid == child_iter->pgid) || pid == child_iter->pid) {
child = child_iter;
break;
}
@ -1395,6 +1396,7 @@ unsigned long do_fork(int clone_flags, unsigned long newsp,
}
new->ftn->pid = new->pid;
new->ftn->pgid = new->pgid;
if (clone_flags & CLONE_PARENT_SETTID) {
dkprintf("clone_flags & CLONE_PARENT_SETTID: 0x%lX\n",