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