Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possibility to configure kill_pgid also via environment variable #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ other features will be added.

catatonit has identical usage to other basic `docker-init`'s -- you give it the
command and list of arguments to that command. If catatonit is not pid1, it
will try to use the sub-reaper support in the kernel. You can pass `-g` if you
want signals to be forwarded to the entire process group of your spawned
process (otherwise it's just forwarded to the process spawned).
will try to use the sub-reaper support in the kernel. You can pass `-g` or set
the `CATATONIT_KILLPG` environment variable if you want signals to be forwarded
to the entire process group of your spawned process (otherwise it's just
forwarded to the process spawned).

If you wish to use catatonit as a convenient pause container (do not spawn a
child process nor do any signal handling), use pass `-P`.
Expand Down
5 changes: 5 additions & 0 deletions catatonit.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ int main(int argc, char **argv)
if (argc < 1 && !run_as_pause)
bail_usage("missing program name");

char *kill_pgid_env = secure_getenv("CATATONIT_KILLPG");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secure_getenv doesn't make sense in this context -- secure_getenv is only relevant for setuid binaries (and even then, it only really makes sense for general purpose libraries that might be used by a setuid binary).

if (kill_pgid_env != NULL) {
kill_pgid = true;
}
Comment on lines +486 to +488
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the Linux kernel style:

Suggested change
if (kill_pgid_env != NULL) {
kill_pgid = true;
}
if (kill_pgid_env)
kill_pgid = true;

or even just do:

Suggested change
if (kill_pgid_env != NULL) {
kill_pgid = true;
}
kill_pgid |= getenv("CATATONIT_KILLPG") != NULL;


/*
* If we aren't pid1, we have to set subreaper or bail. Otherwise zombies
* will collect on the host and that's just not a good idea. We don't just
Expand Down