Android phones start each process in a past life

Source: Internet
Author: User

Have done before a customer apk process open Cap_net_raw permissions, in order to customers can use their own method to crawl TCP/IP packets, the Android Fork has some understanding

First this apk process is zygote fork, the permissions of the zygote process contain cap_net_raw, but the fork after the Android APK permission did a rewrite through Setcapabilities (), You only need to add this cap_net_raw permission when overriding

Here, let's introduce the process.

Fork Fork Fork

1,swapper--swapper--Swapper

--init--Init

--service~

--zygote--zygote

--APK

--Kthreadd

2, first time FORK,KERNEL/INIT/MAIN.C

Rest_init->kernel_thread ();

Second time Fork,android/system/core/init/service.cpp, parse and start init.rc

BOOL Service::start ()->fork ();

Third time Fork,android/frameworks/base/core/jni/com_android_internal_os_zygote.cpp

Static pid_t Forkandspecializecommon ()->fork ()

3, for Kthreadd,kernel to create a new process, the process will be put into kthread_create_list by the Kthreadd process created

4, say again the fork function, fork ()->clone ()->do_fork (), do_fork () completely copy the parent process, except that the child process returns PID=0, and the parent process returns the PID of the child process, which distinguishes

Android phones start each process in a past life

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.