summaryrefslogtreecommitdiff
path: root/proc
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1994-06-30 21:38:09 +0000
committerMichael I. Bushnell <mib@gnu.org>1994-06-30 21:38:09 +0000
commita5954288392f92e680842b4b1370cc514d83f91b (patch)
tree80187f1f1f4cfb0ea7a3993b71eacf94d5574a4c /proc
parent27491f5e2e8cbbda1920c0d8268f2ca11badfb65 (diff)
Formerly pgrp.c.~6~
Diffstat (limited to 'proc')
-rw-r--r--proc/pgrp.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/proc/pgrp.c b/proc/pgrp.c
index ac1e5b48..c8cea52a 100644
--- a/proc/pgrp.c
+++ b/proc/pgrp.c
@@ -273,24 +273,33 @@ S_proc_setpgrp (struct proc *callerp,
pid_t pid,
pid_t pgid)
{
- struct proc *p = pid_find (pid);
- struct pgrp *pg = pgrp_find (pgid);
+ struct proc *p;
+ struct pgrp *pg;
+ p = pid ? pid_find (pid) : callerp;
+
if (!p || (p != callerp && p->p_parent != callerp))
return ESRCH;
if (p->p_parent == callerp && p->p_exec)
return EACCES;
+ if (!pgid)
+ pgid = p->p_pid;
+ pg = pgrp_find (pgid);
+
if (p->p_pgrp->pg_session->s_sid == p->p_pid
|| p->p_pgrp->pg_session != callerp->p_pgrp->pg_session
- || ((pgid != p->p_pgrp->pg_pgid
+ || ((pgid != p->p_pid
&& (!pg || pg->pg_session != callerp->p_pgrp->pg_session))))
return EPERM;
- leave_pgrp (p);
- p->p_pgrp = pg ? pg : new_pgrp (pgid, p->p_pgrp->pg_session);
- join_pgrp (p);
+ if (p->p_pgrp != pg)
+ {
+ leave_pgrp (p);
+ p->p_pgrp = pg ? pg : new_pgrp (pgid, p->p_pgrp->pg_session);
+ join_pgrp (p);
+ }
return 0;
}
@@ -353,8 +362,8 @@ leave_pgrp (struct proc *p)
if (dosignal)
for (ip = pg->pg_plist; ip; ip = ip->p_gnext)
{
- nowait_sig_post (ip->p_msgport, SIGHUP, ip->p_task);
- nowait_sig_post (ip->p_msgport, SIGCONT, ip->p_task);
+ send_signal (ip->p_msgport, SIGHUP, ip->p_task);
+ send_signal (ip->p_msgport, SIGCONT, ip->p_task);
}
}
}