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

Function sys_setsid

freebsd/kern/kern_prot.c:324–358  ·  view source on GitHub ↗

ARGSUSED */

Source from the content-addressed store, hash-verified

322#endif
323/* ARGSUSED */
324int
325sys_setsid(struct thread *td, struct setsid_args *uap)
326{
327 struct pgrp *pgrp;
328 int error;
329 struct proc *p = td->td_proc;
330 struct pgrp *newpgrp;
331 struct session *newsess;
332
333 error = 0;
334 pgrp = NULL;
335
336 newpgrp = uma_zalloc(pgrp_zone, M_WAITOK);
337 newsess = malloc(sizeof(struct session), M_SESSION, M_WAITOK | M_ZERO);
338
339 sx_xlock(&proctree_lock);
340
341 if (p->p_pgid == p->p_pid || (pgrp = pgfind(p->p_pid)) != NULL) {
342 if (pgrp != NULL)
343 PGRP_UNLOCK(pgrp);
344 error = EPERM;
345 } else {
346 (void)enterpgrp(p, p->p_pid, newpgrp, newsess);
347 td->td_retval[0] = p->p_pid;
348 newpgrp = NULL;
349 newsess = NULL;
350 }
351
352 sx_xunlock(&proctree_lock);
353
354 uma_zfree(pgrp_zone, newpgrp);
355 free(newsess, M_SESSION);
356
357 return (error);
358}
359
360/*
361 * set process group (setpgid/old setpgrp)

Callers

nothing calls this directly

Calls 6

mallocFunction · 0.85
enterpgrpFunction · 0.85
pgfindFunction · 0.70
freeFunction · 0.70
uma_zallocFunction · 0.50
uma_zfreeFunction · 0.50

Tested by

no test coverage detected