AOSP Foundations
2 min read

The init Process (Overview)

An introduction to PID 1, the absolute root of the Android user space process tree.

After the Linux kernel finishes its setup and the ramdisk phase pivots to the main system, the operating system is technically running, but it is completely empty. There is no graphical interface, no Wi-Fi, no audio, and no Java framework.

To bring the smartphone to life, a master orchestrator is required. This orchestrator is the init process.

Process ID 1

In Linux (and therefore Android), init is always explicitly assigned Process ID 1 (PID 1). It is the absolute root of the entire user space.

Every single process that runs on your Android phone, from the background Bluetooth daemon to the TikTok app you downloaded from the Play Store, is ultimately a child, grandchild, or great-grandchild of the init process.

If the init process crashes for any reason, the Linux kernel instantly panics and the device violently reboots to protect itself.

# You can verify that init is PID 1 using the process status command
adb shell ps -A | grep "init"
# Output: root  1  0  ... /system/bin/init

The init.rc Language

The init binary itself is written in C++ (located in system/core/init), but it does not hardcode the boot sequence. Instead, it acts as a dynamic parser. It reads plain text configuration files written in a highly specific syntax known as the Android Init Language (.rc files).

The master file is /system/etc/init/hw/init.rc.

This file is essentially a massive script that tells init exactly what to do, in what exact order, to boot the phone.

# Example snippet from an Android init.rc file
on boot
    # Set up power management node
    write /sys/power/wake_lock 1
    
    # Start the core networking daemon
    start netd

Starting Core Services

The primary job of init is to parse these .rc files and spawn the background C++ daemons (services) that make up the Android native layer.

It spawns critical processes like:

  • logd: The daemon that manages all system logs (logcat).
  • servicemanager: The central directory for Binder IPC communication.
  • surfaceflinger: The graphics compositor that draws windows to the screen.
  • audioserver: The daemon that mixes audio streams from different apps.

init acts as the eternal babysitter for these native services. If surfaceflinger crashes due to a bug, init immediately detects the failure and automatically restarts the service to prevent the screen from staying permanently frozen.