Skip to main content

Kill all the orphans of a child process

Project description

Anakin

This is a tool that runs another command, and kills all the orphans it generates.

When a process is killed on Linux, its children are not automatically killed too. Instead they get reparented to the init process and live on. In many cases this is not what you want.

In particular this was written to handle gitlab-runner which runs CI jobs. When a job times out gitlab-runner only kills the process that it started. Any child processes of that may be orphaned and continue running.

Anakin uses Linux's PR_SET_CHILD_SUBREAPER feature to mark itself as the "child subreaper", which means any descendants that are orphaned get reparented to this process, instead of the init process. This process then periodically polls its children and kills any that have been orphaned to it.

Installation

The easiest way to install this is with pip:

python3 -m pip install anakin2

Or if you have Rust:

cargo install anakin

Usage

There are no arguments. Just prefix your command with anakin.

Instead of

my_program --some --args

Run

anakin my_program --some --args

Logging

Logging is controlled by the following environment variables:

  • ANAKIN_LOG, e.g. ANAKIN_LOG=info will print when orphans are killed. The default level is error.
  • ANAKIN_LOG_STYLE controls the colour output. It can be auto (default), always or never.
  • ANAKIN_LOG_FILE if set logs to that filename, plus the process ID. Otherwise it logs to stderr.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

anakin2-0.1.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (928.2 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

File details

Details for the file anakin2-0.1.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for anakin2-0.1.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 620b25775cba9d2b0e37b80bb730a532c55c24d608706c16f24ca5f5c8651310
MD5 8ad7d8111c53d1448b6b678608a34a66
BLAKE2b-256 cca977692c5f3beb7f6be059f4691da40a8f07cdd27c765a1487fc53e10876b9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page