Bash: kill process and all subprocesses without using group idKill all descendant processesProcess...
Would the USA be eligible to join the European Union?
What is a "soap"?
Did Pope Urban II issue the papal bull "terra nullius" in 1095?
What is the prop for Thor's hammer (Mjölnir) made of?
Units of measurement, especially length, when body parts vary in size among races
Can anybody tell me who this Pokemon is?
Stop email from sending using AMPscript
If a person claims to know anything could it be disproven by saying 'prove that we are not in a simulation'?
Why aren't rockets built with truss structures inside their fuel & oxidizer tanks to increase structural strength?
Graphs for which a calculus student can reasonably compute the arclength
Scam? Phone call from "Department of Social Security" asking me to call back
What should I do if actually I found a serious flaw in someone's PhD thesis and an article derived from that PhD thesis?
Number in overlapping range
Why do so many people play out of turn on the last lead?
How do I ask for 2-3 days per week remote work in a job interview?
Is there a word for returning to unpreparedness?
Why does this Jet Provost strikemaster have a textured leading edge?
Is it OK to draw different current from L1 and L2 on NEMA 14-50?
Are there any cons in using rounded corners for bar graphs?
What would cause a nuclear power plant to break down after 2000 years, but not sooner?
Installing Windows to flash UEFI/ BIOS, then reinstalling Ubuntu
What if a restaurant suddenly cannot accept credit cards, and the customer has no cash?
Why won't the Republicans use a superdelegate system like the DNC in their nomination process?
Where is attribute form widget saved
Bash: kill process and all subprocesses without using group id
Kill all descendant processesProcess descendantskill a group of processes with negative PIDWhat is the purpose of abstractions, session, session leader and process groups?Set Parent Process ID from ShellScript, kill all Child Processes laterKill command also kills other processStart new process group in .xinitrcPipe all the suspended processes to killBest way to kill processes created by bash script?How to kill all child processes after parent process died and they all switched to init?linux process group example
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
TL;DR, I need a way to kill a process and all descendant processes, without killing siblings with the same group id, without output printed in the terminal, and with a non-zero exit code.
I have a bash script which is spawning child processes, which spawn grandchild and great grandchild processes.
I want to kill a particular child, and all it's descendants, without using sudo.
Here are some solutions I've tried that don't work for me:
Killing via group id. The child may have sibling processes with the same group id I do not want to kill.
Using
kill $childpid
. This is not killing all grandchildren and great grandchildren processesUsing
kill -9 $childpid
. This leads to text output in terminal that I ran the script from, which is not ideal, even if the script and the kill command both have their stdout and stderr routed to a different fileUsing
pkill -P $childpid
. This seems to do what I want at first, but the child process exits with exit code zero. The parent process needs to know its child was killed prematurely, so I need it to exit with a code other than 0
What is the best way to do this?
Edit: my post has been flagged as a possible duplicate, but all solutions in those links have one of the issues I describe in my post
bash shell-script process job-control jobs
add a comment |
TL;DR, I need a way to kill a process and all descendant processes, without killing siblings with the same group id, without output printed in the terminal, and with a non-zero exit code.
I have a bash script which is spawning child processes, which spawn grandchild and great grandchild processes.
I want to kill a particular child, and all it's descendants, without using sudo.
Here are some solutions I've tried that don't work for me:
Killing via group id. The child may have sibling processes with the same group id I do not want to kill.
Using
kill $childpid
. This is not killing all grandchildren and great grandchildren processesUsing
kill -9 $childpid
. This leads to text output in terminal that I ran the script from, which is not ideal, even if the script and the kill command both have their stdout and stderr routed to a different fileUsing
pkill -P $childpid
. This seems to do what I want at first, but the child process exits with exit code zero. The parent process needs to know its child was killed prematurely, so I need it to exit with a code other than 0
What is the best way to do this?
Edit: my post has been flagged as a possible duplicate, but all solutions in those links have one of the issues I describe in my post
bash shell-script process job-control jobs
2
Possible duplicate of Kill all descendant processes
– Bart
yesterday
and related: unix.stackexchange.com/questions/14815/process-descendants/… unix.stackexchange.com/questions/124127/…
– Bart
yesterday
1
I see this has also been asked at stackoverflow.com/questions/57491869/… It's probably best to remove the question from one of the sites as cross-posted questions are closed on Unix & Linux.
– Anthony Geoghegan
yesterday
@Bart Seems like all the solutions in those threads have one of the 4 issues I address in my post
– quantumbutterfly
6 mins ago
add a comment |
TL;DR, I need a way to kill a process and all descendant processes, without killing siblings with the same group id, without output printed in the terminal, and with a non-zero exit code.
I have a bash script which is spawning child processes, which spawn grandchild and great grandchild processes.
I want to kill a particular child, and all it's descendants, without using sudo.
Here are some solutions I've tried that don't work for me:
Killing via group id. The child may have sibling processes with the same group id I do not want to kill.
Using
kill $childpid
. This is not killing all grandchildren and great grandchildren processesUsing
kill -9 $childpid
. This leads to text output in terminal that I ran the script from, which is not ideal, even if the script and the kill command both have their stdout and stderr routed to a different fileUsing
pkill -P $childpid
. This seems to do what I want at first, but the child process exits with exit code zero. The parent process needs to know its child was killed prematurely, so I need it to exit with a code other than 0
What is the best way to do this?
Edit: my post has been flagged as a possible duplicate, but all solutions in those links have one of the issues I describe in my post
bash shell-script process job-control jobs
TL;DR, I need a way to kill a process and all descendant processes, without killing siblings with the same group id, without output printed in the terminal, and with a non-zero exit code.
I have a bash script which is spawning child processes, which spawn grandchild and great grandchild processes.
I want to kill a particular child, and all it's descendants, without using sudo.
Here are some solutions I've tried that don't work for me:
Killing via group id. The child may have sibling processes with the same group id I do not want to kill.
Using
kill $childpid
. This is not killing all grandchildren and great grandchildren processesUsing
kill -9 $childpid
. This leads to text output in terminal that I ran the script from, which is not ideal, even if the script and the kill command both have their stdout and stderr routed to a different fileUsing
pkill -P $childpid
. This seems to do what I want at first, but the child process exits with exit code zero. The parent process needs to know its child was killed prematurely, so I need it to exit with a code other than 0
What is the best way to do this?
Edit: my post has been flagged as a possible duplicate, but all solutions in those links have one of the issues I describe in my post
bash shell-script process job-control jobs
bash shell-script process job-control jobs
edited 7 mins ago
quantumbutterfly
asked yesterday
quantumbutterflyquantumbutterfly
1113 bronze badges
1113 bronze badges
2
Possible duplicate of Kill all descendant processes
– Bart
yesterday
and related: unix.stackexchange.com/questions/14815/process-descendants/… unix.stackexchange.com/questions/124127/…
– Bart
yesterday
1
I see this has also been asked at stackoverflow.com/questions/57491869/… It's probably best to remove the question from one of the sites as cross-posted questions are closed on Unix & Linux.
– Anthony Geoghegan
yesterday
@Bart Seems like all the solutions in those threads have one of the 4 issues I address in my post
– quantumbutterfly
6 mins ago
add a comment |
2
Possible duplicate of Kill all descendant processes
– Bart
yesterday
and related: unix.stackexchange.com/questions/14815/process-descendants/… unix.stackexchange.com/questions/124127/…
– Bart
yesterday
1
I see this has also been asked at stackoverflow.com/questions/57491869/… It's probably best to remove the question from one of the sites as cross-posted questions are closed on Unix & Linux.
– Anthony Geoghegan
yesterday
@Bart Seems like all the solutions in those threads have one of the 4 issues I address in my post
– quantumbutterfly
6 mins ago
2
2
Possible duplicate of Kill all descendant processes
– Bart
yesterday
Possible duplicate of Kill all descendant processes
– Bart
yesterday
and related: unix.stackexchange.com/questions/14815/process-descendants/… unix.stackexchange.com/questions/124127/…
– Bart
yesterday
and related: unix.stackexchange.com/questions/14815/process-descendants/… unix.stackexchange.com/questions/124127/…
– Bart
yesterday
1
1
I see this has also been asked at stackoverflow.com/questions/57491869/… It's probably best to remove the question from one of the sites as cross-posted questions are closed on Unix & Linux.
– Anthony Geoghegan
yesterday
I see this has also been asked at stackoverflow.com/questions/57491869/… It's probably best to remove the question from one of the sites as cross-posted questions are closed on Unix & Linux.
– Anthony Geoghegan
yesterday
@Bart Seems like all the solutions in those threads have one of the 4 issues I address in my post
– quantumbutterfly
6 mins ago
@Bart Seems like all the solutions in those threads have one of the 4 issues I address in my post
– quantumbutterfly
6 mins ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535527%2fbash-kill-process-and-all-subprocesses-without-using-group-id%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535527%2fbash-kill-process-and-all-subprocesses-without-using-group-id%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Possible duplicate of Kill all descendant processes
– Bart
yesterday
and related: unix.stackexchange.com/questions/14815/process-descendants/… unix.stackexchange.com/questions/124127/…
– Bart
yesterday
1
I see this has also been asked at stackoverflow.com/questions/57491869/… It's probably best to remove the question from one of the sites as cross-posted questions are closed on Unix & Linux.
– Anthony Geoghegan
yesterday
@Bart Seems like all the solutions in those threads have one of the 4 issues I address in my post
– quantumbutterfly
6 mins ago