diff options
author | peter <peter@FreeBSD.org> | 1997-08-19 06:00:27 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-08-19 06:00:27 +0000 |
commit | 738949e1d7f8dd3bbce5dae849e1a03abe404c67 (patch) | |
tree | 9e9f8cf08da103812149608ead3ccc018e684a9c /sys/kern | |
parent | 495bb527c54099728b5a576e7eec0acaf35fecab (diff) | |
download | FreeBSD-src-738949e1d7f8dd3bbce5dae849e1a03abe404c67.zip FreeBSD-src-738949e1d7f8dd3bbce5dae849e1a03abe404c67.tar.gz |
Implement XPG/SYSV-style getpgid()/getsid() syscalls. getpgid() uses the
same syscall number as NetBSD/OpenBSD. The getpgid() came from NetBSD
(I think) originally, but it's basically cut/paste/edit from the other
simple get*() syscalls.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_prot.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 7843b7a..3db74aa 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_prot.c 8.6 (Berkeley) 1/21/94 - * $Id: kern_prot.c,v 1.32 1997/04/02 17:05:49 peter Exp $ + * $Id: kern_prot.c,v 1.33 1997/08/02 14:31:34 bde Exp $ */ /* @@ -107,6 +107,55 @@ getpgrp(p, uap, retval) return (0); } +/* Get an arbitary pid's process group id */ +#ifndef _SYS_SYSPROTO_H_ +struct getpgid_args { + pid_t pid; +}; +#endif + +int +getpgid(p, uap, retval) + struct proc *p; + struct getpgid_args *uap; + int *retval; +{ + if (uap->pid == 0) + goto found; + + if ((p == pfind(uap->pid)) == 0) + return ESRCH; +found: + *retval = p->p_pgrp->pg_id; + return 0; +} + +/* + * Get an arbitary pid's session id. + */ +#ifndef _SYS_SYSPROTO_H_ +struct getsid_args { + pid_t pid; +}; +#endif + +int +getsid(p, uap, retval) + struct proc *p; + struct getsid_args *uap; + int *retval; +{ + if (uap->pid == 0) + goto found; + + if ((p == pfind(uap->pid)) == 0) + return ESRCH; +found: + *retval = p->p_pgrp->pg_session->s_leader->p_pid; + return 0; +} + + #ifndef _SYS_SYSPROTO_H_ struct getuid_args { int dummy; |