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

Function fdunshare

freebsd/kern/kern_descrip.c:2284–2296  ·  view source on GitHub ↗

* Unshare a filedesc structure, if necessary by making a copy */

Source from the content-addressed store, hash-verified

2282 * Unshare a filedesc structure, if necessary by making a copy
2283 */
2284void
2285fdunshare(struct thread *td)
2286{
2287 struct filedesc *tmp;
2288 struct proc *p = td->td_proc;
2289
2290 if (refcount_load(&p->p_fd->fd_refcnt) == 1)
2291 return;
2292
2293 tmp = fdcopy(p->p_fd);
2294 fdescfree(td);
2295 p->p_fd = tmp;
2296}
2297
2298/*
2299 * Unshare a pwddesc structure.

Callers 2

fork_norfprocFunction · 0.85
do_execveFunction · 0.85

Calls 3

refcount_loadFunction · 0.85
fdcopyFunction · 0.85
fdescfreeFunction · 0.85

Tested by

no test coverage detected