Problem with shellscript crashing after âexec kill -SIGINTâ
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have modified a shell script i found here:
https://github.com/Slympp/ConanLinuxScript
But im having troubles with the function "conan_stop"
The script just terminates after
exec kill -SIGINT $pid
The script are sending the kill command successfully but after that it just terminates with no error code or anything.
All the variables in the script are defined earlier in the file.
Full function
function conan_stop grep ConanSandboxServer-Win64-Test.exe
shell-script function
add a comment |Â
up vote
1
down vote
favorite
I have modified a shell script i found here:
https://github.com/Slympp/ConanLinuxScript
But im having troubles with the function "conan_stop"
The script just terminates after
exec kill -SIGINT $pid
The script are sending the kill command successfully but after that it just terminates with no error code or anything.
All the variables in the script are defined earlier in the file.
Full function
function conan_stop grep ConanSandboxServer-Win64-Test.exe
shell-script function
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have modified a shell script i found here:
https://github.com/Slympp/ConanLinuxScript
But im having troubles with the function "conan_stop"
The script just terminates after
exec kill -SIGINT $pid
The script are sending the kill command successfully but after that it just terminates with no error code or anything.
All the variables in the script are defined earlier in the file.
Full function
function conan_stop grep ConanSandboxServer-Win64-Test.exe
shell-script function
I have modified a shell script i found here:
https://github.com/Slympp/ConanLinuxScript
But im having troubles with the function "conan_stop"
The script just terminates after
exec kill -SIGINT $pid
The script are sending the kill command successfully but after that it just terminates with no error code or anything.
All the variables in the script are defined earlier in the file.
Full function
function conan_stop grep ConanSandboxServer-Win64-Test.exe
shell-script function
asked May 29 at 13:25
junkyhlm
20115
20115
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
exec
replaces the shell with the given command, like the exec()
system call. When the command (the kill
, here) stops, the shell no longer exists, so there's no way for the script to continue.
The two exceptions are 1) when exec
is given redirections, in which case it just applies them in the current shell, and 2) when the command can't be executed, in which case exec
gives an error and returns a falsy exit code.
So, exec kill ...
is almost the same as kill ... ; exit
. Not exactly the same, but close enough in this case.
Excellent answer, I totally missed that.
â glenn jackman
May 29 at 15:47
Any thoughts on how to make it better?
â junkyhlm
May 29 at 17:03
In exception 1 as you descibe, can i redirect the kill command and get the script to continue running after the exec() command?
â junkyhlm
May 29 at 17:07
@junkyhlm, "Redirection" refers to input/output redirections. See e.g. mywiki.wooledge.org/BashGuide/InputAndOutput#Redirection and gnu.org/software/bash/manual/html_node/Redirections.html . The thing withexec
here is that there's no reason to use it at all. Just run thekill
command as you'd run any other command. That is, remove theexec
.
â ilkkachu
May 29 at 17:15
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
exec
replaces the shell with the given command, like the exec()
system call. When the command (the kill
, here) stops, the shell no longer exists, so there's no way for the script to continue.
The two exceptions are 1) when exec
is given redirections, in which case it just applies them in the current shell, and 2) when the command can't be executed, in which case exec
gives an error and returns a falsy exit code.
So, exec kill ...
is almost the same as kill ... ; exit
. Not exactly the same, but close enough in this case.
Excellent answer, I totally missed that.
â glenn jackman
May 29 at 15:47
Any thoughts on how to make it better?
â junkyhlm
May 29 at 17:03
In exception 1 as you descibe, can i redirect the kill command and get the script to continue running after the exec() command?
â junkyhlm
May 29 at 17:07
@junkyhlm, "Redirection" refers to input/output redirections. See e.g. mywiki.wooledge.org/BashGuide/InputAndOutput#Redirection and gnu.org/software/bash/manual/html_node/Redirections.html . The thing withexec
here is that there's no reason to use it at all. Just run thekill
command as you'd run any other command. That is, remove theexec
.
â ilkkachu
May 29 at 17:15
add a comment |Â
up vote
4
down vote
accepted
exec
replaces the shell with the given command, like the exec()
system call. When the command (the kill
, here) stops, the shell no longer exists, so there's no way for the script to continue.
The two exceptions are 1) when exec
is given redirections, in which case it just applies them in the current shell, and 2) when the command can't be executed, in which case exec
gives an error and returns a falsy exit code.
So, exec kill ...
is almost the same as kill ... ; exit
. Not exactly the same, but close enough in this case.
Excellent answer, I totally missed that.
â glenn jackman
May 29 at 15:47
Any thoughts on how to make it better?
â junkyhlm
May 29 at 17:03
In exception 1 as you descibe, can i redirect the kill command and get the script to continue running after the exec() command?
â junkyhlm
May 29 at 17:07
@junkyhlm, "Redirection" refers to input/output redirections. See e.g. mywiki.wooledge.org/BashGuide/InputAndOutput#Redirection and gnu.org/software/bash/manual/html_node/Redirections.html . The thing withexec
here is that there's no reason to use it at all. Just run thekill
command as you'd run any other command. That is, remove theexec
.
â ilkkachu
May 29 at 17:15
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
exec
replaces the shell with the given command, like the exec()
system call. When the command (the kill
, here) stops, the shell no longer exists, so there's no way for the script to continue.
The two exceptions are 1) when exec
is given redirections, in which case it just applies them in the current shell, and 2) when the command can't be executed, in which case exec
gives an error and returns a falsy exit code.
So, exec kill ...
is almost the same as kill ... ; exit
. Not exactly the same, but close enough in this case.
exec
replaces the shell with the given command, like the exec()
system call. When the command (the kill
, here) stops, the shell no longer exists, so there's no way for the script to continue.
The two exceptions are 1) when exec
is given redirections, in which case it just applies them in the current shell, and 2) when the command can't be executed, in which case exec
gives an error and returns a falsy exit code.
So, exec kill ...
is almost the same as kill ... ; exit
. Not exactly the same, but close enough in this case.
answered May 29 at 14:42
ilkkachu
47.8k668131
47.8k668131
Excellent answer, I totally missed that.
â glenn jackman
May 29 at 15:47
Any thoughts on how to make it better?
â junkyhlm
May 29 at 17:03
In exception 1 as you descibe, can i redirect the kill command and get the script to continue running after the exec() command?
â junkyhlm
May 29 at 17:07
@junkyhlm, "Redirection" refers to input/output redirections. See e.g. mywiki.wooledge.org/BashGuide/InputAndOutput#Redirection and gnu.org/software/bash/manual/html_node/Redirections.html . The thing withexec
here is that there's no reason to use it at all. Just run thekill
command as you'd run any other command. That is, remove theexec
.
â ilkkachu
May 29 at 17:15
add a comment |Â
Excellent answer, I totally missed that.
â glenn jackman
May 29 at 15:47
Any thoughts on how to make it better?
â junkyhlm
May 29 at 17:03
In exception 1 as you descibe, can i redirect the kill command and get the script to continue running after the exec() command?
â junkyhlm
May 29 at 17:07
@junkyhlm, "Redirection" refers to input/output redirections. See e.g. mywiki.wooledge.org/BashGuide/InputAndOutput#Redirection and gnu.org/software/bash/manual/html_node/Redirections.html . The thing withexec
here is that there's no reason to use it at all. Just run thekill
command as you'd run any other command. That is, remove theexec
.
â ilkkachu
May 29 at 17:15
Excellent answer, I totally missed that.
â glenn jackman
May 29 at 15:47
Excellent answer, I totally missed that.
â glenn jackman
May 29 at 15:47
Any thoughts on how to make it better?
â junkyhlm
May 29 at 17:03
Any thoughts on how to make it better?
â junkyhlm
May 29 at 17:03
In exception 1 as you descibe, can i redirect the kill command and get the script to continue running after the exec() command?
â junkyhlm
May 29 at 17:07
In exception 1 as you descibe, can i redirect the kill command and get the script to continue running after the exec() command?
â junkyhlm
May 29 at 17:07
@junkyhlm, "Redirection" refers to input/output redirections. See e.g. mywiki.wooledge.org/BashGuide/InputAndOutput#Redirection and gnu.org/software/bash/manual/html_node/Redirections.html . The thing with
exec
here is that there's no reason to use it at all. Just run the kill
command as you'd run any other command. That is, remove the exec
.â ilkkachu
May 29 at 17:15
@junkyhlm, "Redirection" refers to input/output redirections. See e.g. mywiki.wooledge.org/BashGuide/InputAndOutput#Redirection and gnu.org/software/bash/manual/html_node/Redirections.html . The thing with
exec
here is that there's no reason to use it at all. Just run the kill
command as you'd run any other command. That is, remove the exec
.â ilkkachu
May 29 at 17:15
add a comment |Â
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%2f446695%2fproblem-with-shellscript-crashing-after-exec-kill-sigint%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