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

unshare: Add --kill-child option #511

Merged
merged 4 commits into from Oct 23, 2017

Conversation

Projects
None yet
2 participants
@nh2
Copy link
Contributor

commented Sep 19, 2017

This allows to conveniently kill the entire process tree
below the forked program, a common problem when scripting
tasks that need to reliably fully terminate without leaving
reparented subprocesses behind.

The example added to the man page shows the most common use.

Implemented using prctl(PR_SET_PDEATHSIG, ...).

@nh2

This comment has been minimized.

Copy link
Contributor Author

commented Sep 19, 2017

Please let me know if you'd prefer if the user could provide a specific signal to be sent, instead of the current fixed use of SIGKILL.

@karelzak

This comment has been minimized.

Copy link
Owner

commented Oct 2, 2017

Thanks. I'm going to postpone this for the next release (v2.32) - it's too late for v2.31.

Maybe it would be nice to have an optional argument for the

 --kill-child[=<signame>]

where signame is SIGKILL by default. Note that with in misc-utils/kill.c we have table to convert name to signal number. The ideal solution would be to move (by another patch) the table and signame_to_signum() to lib/signames.c and use it in kill.c as well as in unshare.c.

@karelzak karelzak added POSTPONED NOT-READY and removed POSTPONED labels Oct 2, 2017

@nh2

This comment has been minimized.

Copy link
Contributor Author

commented Oct 2, 2017

Note that with in misc-utils/kill.c we have table to convert name to signal number.

Ah great, that would be my next question.

Sounds like a good plan!

nh2 referenced this pull request in hashicorp/consul Oct 10, 2017

Kill check processes after the timeout is reached
Kill the subprocess spawned by a script check once the timeout is reached. Previously Consul just marked the check critical and left the subprocess around.

Fixes #3565.

nh2 added some commits Sep 19, 2017

unshare: Add --kill-child option.
This allows to conveniently kill the entire process tree
below the forked program, a common problem when scripting
tasks that need to reliably fully terminate without leaving
reparented subprocesses behind.

The example added to the man page shows the most common use.

Implemented using prctl(PR_SET_PDEATHSIG, ...).

@nh2 nh2 force-pushed the nh2:kill-child-feature branch from 19bfd91 to 8b39a17 Oct 14, 2017

@nh2

This comment has been minimized.

Copy link
Contributor Author

commented Oct 14, 2017

@karelzak I've pushed some new commits, please let me know if that's how you had it in mind.

Note the static const struct signv ... sys_signame[] went into a signames.h so that ARRAY_SIZE(sys_signame) as used in kill.c still works, not sure if that's OK.

@karelzak karelzak removed the NOT-READY label Oct 17, 2017

@karelzak

This comment has been minimized.

Copy link
Owner

commented Oct 17, 2017

Seems good. I'll merge it after v2.31 release (later this week or so..). Thanks!

@karelzak karelzak merged commit 8b39a17 into karelzak:master Oct 23, 2017

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
@nh2

This comment has been minimized.

Copy link
Contributor Author

commented Oct 29, 2017

@karelzak Thanks for helping get this in! It was a very smooth experience.

nh2 added a commit to nh2/util-linux that referenced this pull request Nov 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.