| 820 | } |
| 821 | |
| 822 | int |
| 823 | fork1(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 | */ |
no test coverage detected