MCPcopy Create free account
hub / github.com/F-Stack/f-stack / procdesc_find

Function procdesc_find

freebsd/kern/sys_procdesc.c:123–149  ·  view source on GitHub ↗

* Return a locked process given a process descriptor, or ESRCH if it has * died. */

Source from the content-addressed store, hash-verified

121 * died.
122 */
123int
124procdesc_find(struct thread *td, int fd, cap_rights_t *rightsp,
125 struct proc **p)
126{
127 struct procdesc *pd;
128 struct file *fp;
129 int error;
130
131 error = fget(td, fd, rightsp, &fp);
132 if (error)
133 return (error);
134 if (fp->f_type != DTYPE_PROCDESC) {
135 error = EBADF;
136 goto out;
137 }
138 pd = fp->f_data;
139 sx_slock(&proctree_lock);
140 if (pd->pd_proc != NULL) {
141 *p = pd->pd_proc;
142 PROC_LOCK(*p);
143 } else
144 error = ESRCH;
145 sx_sunlock(&proctree_lock);
146out:
147 fdrop(fp, td);
148 return (error);
149}
150
151/*
152 * Function to be used by procstat(1) sysctls when returning procdesc

Callers 1

sys_pdkillFunction · 0.85

Calls 1

fgetFunction · 0.85

Tested by

no test coverage detected