Prevent children to be stopped by SIGTERM
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I wrote this script (I removed some useless stuff):
#!/bin/bash
readonly ARGS="$@"
catch()
echo "Sigterm caught"
# Perform some cleanup instructions
# that suppose the child process is still alive
trap - SIGTERM # remove the trap
kill -s SIGINT -- -$$ # Sends SIGINT to child/sub processes
exit 0
main()
trap "catch $5 $4" SIGTERM
./child_process_program # With all arguments needed
main $ARGS
I start this script with the script as follows: timeout "10s" ./my_script <arguments>
.
The problem is that sigterm reaches also the child_process_program and so the instructions that suppose the child process is still alive cannot succeed.
I already see a very similar question with answer and tried (unsuccessfully) to change main as follows:
main()
trap "catch $5 $4" SIGTERM
set -m
./child_process_program & # With all arguments needed
But I did not succeed. Is there a solution to my problem?
bash signals
add a comment |Â
up vote
1
down vote
favorite
I wrote this script (I removed some useless stuff):
#!/bin/bash
readonly ARGS="$@"
catch()
echo "Sigterm caught"
# Perform some cleanup instructions
# that suppose the child process is still alive
trap - SIGTERM # remove the trap
kill -s SIGINT -- -$$ # Sends SIGINT to child/sub processes
exit 0
main()
trap "catch $5 $4" SIGTERM
./child_process_program # With all arguments needed
main $ARGS
I start this script with the script as follows: timeout "10s" ./my_script <arguments>
.
The problem is that sigterm reaches also the child_process_program and so the instructions that suppose the child process is still alive cannot succeed.
I already see a very similar question with answer and tried (unsuccessfully) to change main as follows:
main()
trap "catch $5 $4" SIGTERM
set -m
./child_process_program & # With all arguments needed
But I did not succeed. Is there a solution to my problem?
bash signals
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I wrote this script (I removed some useless stuff):
#!/bin/bash
readonly ARGS="$@"
catch()
echo "Sigterm caught"
# Perform some cleanup instructions
# that suppose the child process is still alive
trap - SIGTERM # remove the trap
kill -s SIGINT -- -$$ # Sends SIGINT to child/sub processes
exit 0
main()
trap "catch $5 $4" SIGTERM
./child_process_program # With all arguments needed
main $ARGS
I start this script with the script as follows: timeout "10s" ./my_script <arguments>
.
The problem is that sigterm reaches also the child_process_program and so the instructions that suppose the child process is still alive cannot succeed.
I already see a very similar question with answer and tried (unsuccessfully) to change main as follows:
main()
trap "catch $5 $4" SIGTERM
set -m
./child_process_program & # With all arguments needed
But I did not succeed. Is there a solution to my problem?
bash signals
I wrote this script (I removed some useless stuff):
#!/bin/bash
readonly ARGS="$@"
catch()
echo "Sigterm caught"
# Perform some cleanup instructions
# that suppose the child process is still alive
trap - SIGTERM # remove the trap
kill -s SIGINT -- -$$ # Sends SIGINT to child/sub processes
exit 0
main()
trap "catch $5 $4" SIGTERM
./child_process_program # With all arguments needed
main $ARGS
I start this script with the script as follows: timeout "10s" ./my_script <arguments>
.
The problem is that sigterm reaches also the child_process_program and so the instructions that suppose the child process is still alive cannot succeed.
I already see a very similar question with answer and tried (unsuccessfully) to change main as follows:
main()
trap "catch $5 $4" SIGTERM
set -m
./child_process_program & # With all arguments needed
But I did not succeed. Is there a solution to my problem?
bash signals
asked Jun 5 at 21:19
Briomkez
1133
1133
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f448084%2fprevent-children-to-be-stopped-by-sigterm%23new-answer', 'question_page');
);
Post as a guest
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
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
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