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

Function fork1

freebsd/kern/kern_fork.c:822–1030  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

820}
821
822int
823fork1(struct thread *td, struct fork_req *fr)
824{
825 struct proc *p1, *newproc;
826 struct thread *td2;
827 struct vmspace *vm2;
828 struct ucred *cred;
829 struct file *fp_procdesc;
830 vm_ooffset_t mem_charged;
831 int error, nprocs_new;
832 static int curfail;
833 static struct timeval lastfail;
834 int flags, pages;
835
836 flags = fr->fr_flags;
837 pages = fr->fr_pages;
838
839 if ((flags & RFSTOPPED) != 0)
840 MPASS(fr->fr_procp != NULL && fr->fr_pidp == NULL);
841 else
842 MPASS(fr->fr_procp == NULL);
843
844 /* Check for the undefined or unimplemented flags. */
845 if ((flags & ~(RFFLAGS | RFTSIGFLAGS(RFTSIGMASK))) != 0)
846 return (EINVAL);
847
848 /* Signal value requires RFTSIGZMB. */
849 if ((flags & RFTSIGFLAGS(RFTSIGMASK)) != 0 && (flags & RFTSIGZMB) == 0)
850 return (EINVAL);
851
852 /* Can't copy and clear. */
853 if ((flags & (RFFDG|RFCFDG)) == (RFFDG|RFCFDG))
854 return (EINVAL);
855
856 /* Check the validity of the signal number. */
857 if ((flags & RFTSIGZMB) != 0 && (u_int)RFTSIGNUM(flags) > _SIG_MAXSIG)
858 return (EINVAL);
859
860 if ((flags & RFPROCDESC) != 0) {
861 /* Can't not create a process yet get a process descriptor. */
862 if ((flags & RFPROC) == 0)
863 return (EINVAL);
864
865 /* Must provide a place to put a procdesc if creating one. */
866 if (fr->fr_pd_fd == NULL)
867 return (EINVAL);
868
869 /* Check if we are using supported flags. */
870 if ((fr->fr_pd_flags & ~PD_ALLOWED_AT_FORK) != 0)
871 return (EINVAL);
872 }
873
874 p1 = td->td_proc;
875
876 /*
877 * Here we don't create a new process, but we divorce
878 * certain parts of a process from itself.
879 */

Callers 6

sys_forkFunction · 0.85
sys_pdforkFunction · 0.85
sys_vforkFunction · 0.85
sys_rforkFunction · 0.85
create_initFunction · 0.85
kproc_createFunction · 0.85

Calls 15

fork_norfprocFunction · 0.85
procdesc_fallocFunction · 0.85
thread_allocFunction · 0.85
proc_linkupFunction · 0.85
vm_thread_disposeFunction · 0.85
thread_alloc_stackFunction · 0.85
vmspace_forkFunction · 0.85
swap_reserveFunction · 0.85
swap_reserve_forceFunction · 0.85
proc_set_cred_initFunction · 0.85
mac_proc_initFunction · 0.85
knlist_allocFunction · 0.85

Tested by

no test coverage detected