FreeBSD/sys/kern/sys_procdesc.c
/*
 * Return a locked process given a process descriptor, or ESRCH if it has
 * died.
 */
Return a locked process given a process descriptor, or ESRCH if it has
died.
Return a locked process given a process descriptor or ESRCH if it has died .
int
procdesc_find(struct thread *td, int fd, cap_rights_t *rightsp,
    struct proc **p)
{
	struct procdesc *pd;
	struct file *fp;
	int error;
	error = fget(td, fd, rightsp, &fp);
	if (error)
		return (error);
	if (fp->f_type != DTYPE_PROCDESC) {
		error = EBADF;
		goto out;
	}
	pd = fp->f_data;
	sx_slock(&proctree_lock);
	if (pd->pd_proc != NULL) {
		*p = pd->pd_proc;
		PROC_LOCK(*p);
	} else
		error = ESRCH;
	sx_sunlock(&proctree_lock);
out:
	fdrop(fp, td);
	return (error);
}
int procdesc_find ( struct thread * td , int fd , cap_rights_t * rightsp , struct proc * * p ) { struct procdesc * pd ; struct file * fp ; int error ; error = fget ( td , fd , rightsp , & fp ) ; if ( error ) return ( error ) ; if ( fp -> f_type != DTYPE_PROCDESC ) { error = EBADF ; goto out ; } pd = fp -> f_data ; sx_slock ( & proctree_lock ) ; if ( pd -> pd_proc != NULL ) { * p = pd -> pd_proc ; PROC_LOCK ( * p ) ; } else error = ESRCH ; sx_sunlock ( & proctree_lock ) ; out : fdrop ( fp , td ) ; return ( error ) ; }
Return a locked process given a process descriptor, or ESRCH if it has
 died.
Return a locked process given a process descriptor or ESRCH if it has died .