Problem with shellscript crashing after “exec kill -SIGINT”

The name of the pictureThe name of the pictureThe name of the pictureClash 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 






share|improve this question























    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 






    share|improve this question





















      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 






      share|improve this question











      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 








      share|improve this question










      share|improve this question




      share|improve this question









      asked May 29 at 13:25









      junkyhlm

      20115




      20115




















          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.






          share|improve this answer





















          • 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 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










          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          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






























          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.






          share|improve this answer





















          • 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 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














          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.






          share|improve this answer





















          • 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 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












          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.






          share|improve this answer













          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.







          share|improve this answer













          share|improve this answer



          share|improve this answer











          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 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
















          • 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 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















          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












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          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













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay