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 iserror
.ANAKIN_LOG_STYLE
controls the colour output. It can beauto
(default),always
ornever
.ANAKIN_LOG_FILE
if set logs to that filename, plus the process ID. Otherwise it logs to stderr.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file anakin2-0.1.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: anakin2-0.1.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 928.2 kB
- Tags: Python 3, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 620b25775cba9d2b0e37b80bb730a532c55c24d608706c16f24ca5f5c8651310 |
|
MD5 | 8ad7d8111c53d1448b6b678608a34a66 |
|
BLAKE2b-256 | cca977692c5f3beb7f6be059f4691da40a8f07cdd27c765a1487fc53e10876b9 |