首页 Function Compute Function Compute FAQ Code development Custom runtime FAQ How to avoid zombie processes in a custom runtime?

How to avoid zombie processes in a custom runtime?

更新时间: 2026-04-01 05:55:46

Cause

Zombie processes can occur because of issues in your code.

When you create a Web Function and configure a Startup Command, Function Compute assigns your start command as process ID (PID) 1. By default, most application processes running as PID 1 do not reap child processes — meaning child processes that exit remain in the process table as zombie processes until PID 1 collects their exit status. To prevent this, configure a start command that can reap zombie processes.

Option 1: Wrap your application in a Bash script (recommended)

Bash, when running as PID 1, automatically reaps zombie child processes. Set the Startup Command to a Bash wrapper script instead of running your application directly.

Steps

  1. Create /code/start.sh with the following content:

    #! /bin/bash
    python /code/app.py
  2. Set the Startup Command to /code/start.sh.

Option 2: Use a bootstrap file (Serverless Devs and API deployments)

If you deploy using Serverless Devs or the API, omit the Startup Command entirely and name your start script bootstrap. When no Startup Command is configured, Function Compute automatically runs /code/bootstrap to start the function.

Like Option 1, wrap your application in Bash to ensure PID 1 reaping:

#! /bin/bash
python /code/app.py
上一篇: How to convert file formats using the Function Compute WebIDE 下一篇: Custom Container FAQ
阿里云首页 函数计算 相关技术圈