Skip to main content

Fix [Process completed (signal 9) - press Enter] for Termux on Android 12+ devices

Smartphone Termux Tutorial Termux
Table of Contents

🇹🇼 中文版

After installing Ubuntu proot-distro in Termux, you open Real VNC Viewer to connect to the vncserver, however it says: The connection closed unexpectedly. Then you go back to Termux, see a message [Process completed (signal 9) - press Enter] and Termux is forced to quit.

That means the Termux processes are killed by Android OS. This will occur on Android 12+ devices. Fortunately this could be solved by executing some commands.

In this article, I will discuss the causes and solutions for Termux proceesses killing.

1. The causes of signal 9 error
#

According to agnostic-apollo’s article Phantom, Cached And Empty Processes, on Android 12 a new mechanism was added for Android system to monitor forked processes by the apps. They were named “Phantom processes”. And DEFAULT_MAX_PHANTOM_PROCESSES (default=32, all apps combined, not per app) defines how many processes are allowed to run before got killed by the system.

They were named “Phantom” because they were designed to give android devs nightmares when then saw them (allegedly of course).

Such feature could prevent apps from using excessive CPU powers. However it is harmful to Termux commands. While running services in the background, Termux is likely to be killed by system by anytime. That is why vncserver got terminated when you try to connect to the vncserver.

After that, Google added a new flag settings_enable_monitor_phantom_procs for disabling Phantom Processes Killing, though it was enabled by default on all Android devices.

The Phantom Processes Killing could be dsiabled by executing ADB commands. These commands are provided by agnostic-apollo.

2. How to solve signal 9 error
#

Use these commands at your own risks! Disabling Phantom Processes Killing may cause bootloop or make some apps in background lost control.

It is assumed that Google Services Framework is installed on your phone. We will disable its auto config syncing to prevent GMS from overriding the configs.

Here is a video for your reference

2.1. For non-rooted devices
#

Note: These steps require a PC. If you don’t have a PC, try running ADB in Termux instead. See this Reddit post

  1. Download Platform tools for Windows at Android Developers. Extract the archive.

  2. Open terminal in platform_tools directory. (SHIFT + Right click → Open Windows Terminal or Powershell)

  3. Open System Settings on Android, go to “About phone”, click five times on “build number”. Search “Developer options” and enable ADB debugging there.

  4. Connect the phone to PC. Execute this command and agree ADB debugging on Android phone.

./adb devices
  1. Execute commands according to your Android version. Then reboot.
# For Android 12L & Android 13:
./adb shell "settings put global settings_enable_monitor_phantom_procs false"

# For Android 12:
./adb shell "/system/bin/device_config set_sync_disabled_for_tests persistent; /system/bin/device_config put activity_manager max_phantom_processes 2147483647"

2.2. For rooted devices
#

  1. Open Termux, switch to su and grant root permission.
su
  1. Execute commands according to your Android version. Then reboot.
# For Android 12L & Android 13:
su -c "settings put global settings_enable_monitor_phantom_procs false"

# For Android 12:
su -c "/system/bin/device_config set_sync_disabled_for_tests persistent; /system/bin/device_config put activity_manager max_phantom_processes 2147483647"

Related

Run Windows exe on Android through Proot Exagear on Termux
Smartphone Termux Tutorial Termux Windows Android
[Root] Box86 + Wine in 64bit chroot on Android
Smartphone Termux Tutorial Termux
[Root] Running docker container on Redmi Note 5 Pro
Smartphone Root and Custom Rom Termux Android Linux Docker

Leave a comment

Choose the comment system you like. Giscus for codes, Disqus for anonymous comments.

Please login to your Github account to leave a comment. You can post codes here for discussion. For images, please upload to Imgur and copy links. Your comments would be visible to everyone on Github Discussions.

This comment system is provided by Disqus, you may see forcing Disqus ADs on this page. Sometimes your comment may need to be reviewed, resulting in delayed display. Thank you for your understanding.