03 The init process of Android startup

The init process started by Android

1. Analyze what the init process has done?

The init process, when the linux kernel starts, the first one to run is init. The entry file of the Android init process is in system/core/init/init.cpp. Since init is a command-line program, the analysis of init.cpp starts from The main function begins.

  • The init main function starts: create a directory, mount the file system, and initialize the log system; //start ueventd //start watchdogd //umask(0); //clear the mask word//mount the tmpfs file system//mount the devpts file System//mount proc file system//mount sysfs file system

  • The first stage of init: Initialize the selinux system //init: Loading SELinux policy

  • The second phase of init: Initialize the property field //Detect whether the /dev/.booting file is readable and writable //property_init(); //Initialize the property field – defined in system/core/init/property_service.cpp //process_kernel_cmdline() ;//Process kernel commands

  • Start selinux and reset the selinux permissions on the directory

  • Call epoll_create1 to create epoll handle //epoll_fd = epoll_create1(EPOLL_CLOEXEC);//Call epoll_create1 to create epoll handle

  • Install the signal handler in the child process:

sigchld_handler_init();

//When the init process calls sigchld_handler_init, once it receives the SIGCHLID message brought by the termination of the child process

Guess you like

Origin blog.csdn.net/Johnny2004/article/details/130805254