Function report |
Source Code:kernel\fork.c |
Create Date:2022-07-28 08:58:37 |
Last Modify:2020-03-17 11:04:53 | Copyright©Brick |
home page | Tree |
Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:Create a new process
Proto:static __latent_entropy struct task_struct *copy_process(struct pid *pid, int trace, int node, struct kernel_clone_args *args)
Type:struct task_struct
Parameter:
Type | Parameter | Name |
---|---|---|
struct pid * | pid | |
int | trace | |
int | node | |
struct kernel_clone_args * | args |
1830 | pidfd = -1 |
1834 | clone_flags = flags |
1840 | If (clone_flags & (New mount namespace group | set if fs info shared between processes )) == (New mount namespace group | set if fs info shared between processes ) Then Return ERR_PTR( - EINVAL) |
1843 | If (clone_flags & (New user namespace | set if fs info shared between processes )) == (New user namespace | set if fs info shared between processes ) Then Return ERR_PTR( - EINVAL) |
1850 | If clone_flags & Same thread group && Not (clone_flags & set if signal handlers and blocked signals shared ) Then Return ERR_PTR( - EINVAL) |
1858 | If clone_flags & set if signal handlers and blocked signals shared && Not (clone_flags & set if VM shared between processes ) Then Return ERR_PTR( - EINVAL) |
1867 | If clone_flags & set if we want to have the same parent as the cloner && flags & r init: ignore fatal signals Then Return ERR_PTR( - EINVAL) |
1875 | If clone_flags & Same thread group Then |
1876 | If clone_flags & (New user namespace | New pid namespace ) || task_active_pid_ns(current process) != pid_ns_for_children Then Return ERR_PTR( - EINVAL) |
1882 | If clone_flags & set if a pidfd should be placed in parent Then |
1888 | If clone_flags & (Unused, ignored | Same thread group) Then Return ERR_PTR( - EINVAL) |
1898 | sigemptyset( & signal) |
1899 | INIT_HLIST_NODE( & node) |
1901 | spin_lock_irq( & siglock) |
1902 | If Not (clone_flags & Same thread group) Then hlist_add_head( & node, & multiprocess) |
1904 | recalc_sigpending() |
1905 | spin_unlock_irq( & siglock) |
1906 | retval = -ERESTARTNOINTR |
1907 | If signal_pending(current process) Then Go to fork_out |
1921 | CLONE_CHILD_SETTID: = (clone_flags & set the TID in the child ) ? child_tid : NULL |
1925 | CLONE_CHILD_CLEARTID: = (clone_flags & clear the TID in the child ) ? child_tid : NULL |
1927 | ftrace_graph_init_task(p) |
1936 | If atomic_read( & processes) >= task_rlimit(p, RLIMIT_NPROC) Then |
1938 | If real user ID subscription != INIT_USER && Not Check operation authority && Not Check operation authority Then Go to bad_fork_free |
1944 | retval = copy_creds(p, clone_flags) |
1945 | If retval < 0 Then Go to bad_fork_free |
1954 | If counter of threads >= unable limit on nr_threads Then Go to bad_fork_cleanup_count |
1958 | Per task flags (PF_*), defined further below: &= ~( Used super-user privileges | I'm a workqueue worker | I am an IDLE thread ) |
1962 | rcu_copy_process(p) |
1963 | vfork_done = NULL |
1964 | Process spin lock initialization( & Protection against (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed, mempolicy: ) |
1972 | prev_cputime_init( & prev_cputime) |
1991 | clear integrals |
1995 | io_context = NULL |
1996 | audit_set_context(p, NULL) |
1997 | cgroup_fork(p) |
2000 | If IS_ERR( Protected by alloc_lock: ) Then |
2001 | retval = PTR_ERR( Protected by alloc_lock: ) |
2002 | Protected by alloc_lock: = NULL |
2003 | Go to bad_fork_cleanup_threadgroup_lock |
2027 | pagefault_disabled = 0 |
2042 | retval = sched_fork(clone_flags, p) |
2043 | If retval Then Go to bad_fork_cleanup_policy |
2046 | retval = perf_event_init_task(p) |
2047 | If retval Then Go to bad_fork_cleanup_policy |
2049 | retval = audit_alloc(p) |
2050 | If retval Then Go to bad_fork_cleanup_perf |
2053 | shm_init_task(p) |
2054 | retval = security_task_alloc(p, clone_flags) |
2055 | If retval Then Go to bad_fork_cleanup_audit |
2057 | retval = copy_semundo(clone_flags, p) |
2058 | If retval Then Go to bad_fork_cleanup_security |
2060 | retval = copy_files(clone_flags, p) |
2061 | If retval Then Go to bad_fork_cleanup_semundo |
2063 | retval = copy_fs(clone_flags, p) |
2064 | If retval Then Go to bad_fork_cleanup_files |
2066 | retval = copy_sighand(clone_flags, p) |
2067 | If retval Then Go to bad_fork_cleanup_fs |
2069 | retval = copy_signal(clone_flags, p) |
2070 | If retval Then Go to bad_fork_cleanup_sighand |
2072 | retval = copy_mm(clone_flags, p) |
2073 | If retval Then Go to bad_fork_cleanup_signal |
2076 | If retval Then Go to bad_fork_cleanup_mm |
2078 | retval = copy_io(clone_flags, p) |
2079 | If retval Then Go to bad_fork_cleanup_namespaces |
2081 | retval = Architectures that haven't opted into copy_thread_tls get the tls argument* via pt_regs, so ignore the tls argument passed via C. |
2083 | If retval Then Go to bad_fork_cleanup_io |
2086 | stackleak_task_init(p) |
2088 | If pid != init_struct_pid Then |
2093 | Go to bad_fork_cleanup_thread |
2102 | If clone_flags & set if a pidfd should be placed in parent Then |
2103 | retval = get_unused_fd_flags(O_RDWR | O_CLOEXEC) |
2104 | If retval < 0 Then Go to bad_fork_free_pid |
2109 | pidfile = anon_inode_getfile("[pidfd]", & pidfd_fops, pid, O_RDWR | O_CLOEXEC) |
2119 | If retval Then Go to bad_fork_put_pidfd |
2124 | Stack plugging: = NULL |
2126 | futex_init_task(p) |
2131 | If (clone_flags & (set if VM shared between processes | set if the parent wants the child to wake it up on mm_release )) == set if VM shared between processes Then sas_ss_reset(p) |
2138 | user_disable_single_step(p) |
2143 | clear_tsk_latency_tracing(p) |
2147 | If clone_flags & Same thread group Then |
2151 | Else |
2152 | If clone_flags & set if we want to have the same parent as the cloner Then exit signal = exit_signal |
2154 | Else exit signal = exit_signal |
2156 | group_leader = p |
2157 | thread group id = process id |
2161 | nr_dirtied_pause = 128 >> PAGE_SHIFT determines the page size - 10 |
2162 | Start of a write-and-pause period: = 0 |
2164 | The signal sent when the parent dies = 0 |
2166 | task_works = NULL |
2175 | retval = cgroup_can_fork(p) |
2176 | If retval Then Go to bad_fork_cgroup_threadgroup_change_end |
2187 | Monotonic time in nsecs: = ktime_get_ns() |
2194 | write_lock_irq( & tasklist_lock) |
2197 | If clone_flags & (set if we want to have the same parent as the cloner | Same thread group) Then |
2198 | Real parent process: = real_parent |
2200 | Else |
2205 | klp_copy_process(p) |
2213 | copy_seccomp(p) |
2215 | rseq_fork(p, clone_flags) |
2218 | If Value for the false possibility is greater at compile time(!(pid_allocated & PIDNS_ADDING)) Then |
2220 | Go to bad_fork_cancel_cgroup |
2224 | If fatal_signal_pending(current process) Then |
2226 | Go to bad_fork_cancel_cgroup |
2230 | If pidfile Then fd_install(pidfd, pidfile) |
2233 | init_task_pid_links(p) |
2234 | If Value is more likely to compile time(process id) Then |
2237 | init_task_pid(p, PIDTYPE_PID, pid) |
2238 | If thread_group_leader(p) Then |
2239 | init_task_pid(p, PIDTYPE_TGID, pid) |
2241 | init_task_pid(p, PIDTYPE_SID, task_session(current process)) |
2244 | child_reaper = p |
2261 | __this_cpu_inc(process_counts) |
2262 | Else |
2273 | counter of threads++ |
2275 | Handle normal Linux uptimes. ++ |
2276 | hlist_del_init( & node) |
2277 | spin_unlock( & siglock) |
2278 | syscall_tracepoint_update(p) |
2279 | write_unlock_irq( & tasklist_lock) |
2281 | proc_fork_connector(p) |
2282 | cgroup_post_fork(p) |
2284 | perf_event_fork(p) |
2286 | trace_task_newtask(p, clone_flags) |
2287 | uprobe_copy_process(p, clone_flags) |
2289 | Return p |
2291 | bad_fork_cancel_cgroup : |
2292 | spin_unlock( & siglock) |
2293 | write_unlock_irq( & tasklist_lock) |
2294 | cgroup_cancel_fork(p) |
2297 | bad_fork_put_pidfd : |
2298 | If clone_flags & set if a pidfd should be placed in parent Then |
2300 | put_unused_fd(pidfd) |
2302 | bad_fork_free_pid : |
2303 | If pid != init_struct_pid Then free_pid(pid) |
2305 | bad_fork_cleanup_thread : |
2306 | exit_thread(p) |
2307 | bad_fork_cleanup_io : |
2308 | If io_context Then exit_io_context(p) |
2310 | bad_fork_cleanup_namespaces : |
2311 | exit_task_namespaces(p) |
2312 | bad_fork_cleanup_mm : |
2313 | If mm Then |
2317 | bad_fork_cleanup_signal : |
2318 | If Not (clone_flags & Same thread group) Then free_signal_struct( Signal handlers: ) |
2320 | bad_fork_cleanup_sighand : |
2321 | __cleanup_sighand(sighand) |
2322 | bad_fork_cleanup_fs : |
2324 | bad_fork_cleanup_files : |
2325 | exit_files(p) |
2326 | bad_fork_cleanup_semundo : |
2328 | bad_fork_cleanup_security : |
2329 | security_task_free(p) |
2330 | bad_fork_cleanup_audit : |
2331 | audit_free(p) |
2332 | bad_fork_cleanup_perf : |
2333 | perf_event_free_task(p) |
2334 | bad_fork_cleanup_policy : |
2335 | lockdep_free_task(p) |
2337 | mpol_put( Protected by alloc_lock: ) |
2340 | delayacct_tsk_free(p) |
2341 | bad_fork_cleanup_count : |
2342 | atomic_dec( & processes) |
2343 | exit_creds(p) |
2344 | bad_fork_free : |
2346 | put_task_stack(p) |
2347 | delayed_free_task(p) |
2348 | fork_out : |
2349 | spin_lock_irq( & siglock) |
2350 | hlist_del_init( & node) |
2351 | spin_unlock_irq( & siglock) |
Source code conversion tool public plug-in interface | X |
---|---|
Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |