Closing a Specific Terminal












1















I have a program that opens a new terminal and runs while loop, but when the program ends I want to terminate this window. Is it possible to close a certain terminal window with a command, while keeping all other terminals open?










share|improve this question



























    1















    I have a program that opens a new terminal and runs while loop, but when the program ends I want to terminate this window. Is it possible to close a certain terminal window with a command, while keeping all other terminals open?










    share|improve this question

























      1












      1








      1








      I have a program that opens a new terminal and runs while loop, but when the program ends I want to terminate this window. Is it possible to close a certain terminal window with a command, while keeping all other terminals open?










      share|improve this question














      I have a program that opens a new terminal and runs while loop, but when the program ends I want to terminate this window. Is it possible to close a certain terminal window with a command, while keeping all other terminals open?







      14.04 gnome-terminal






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 7 '16 at 19:43









      Unnecessary BeesUnnecessary Bees

      133




      133






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Njap



          The easy way: Create a variable that the while loop tests for true (or false, whatever way you like) and change this var to end the loop.



          The complicated way:
          Get the Pid of you Shell:



          $ echo $$


          returns e.g.



          1441


          The Shell (e.g. bash) runs in the Terminal, so the Terminal is identified by bashs parent PID. Get ppid:



          $ cat /proc/1441/status | grep PPid


          returns e.g.



          1432


          If you can Pid it, you can kill it. ;)



          $ kill 1432


          EDIT: There might be easier ways to get the Pid of the program process, e.g. if the program has a specific name, you can



          $ ps aux | grep nameofmyspecificprogram



          for it.






          share|improve this answer


























          • Use pgrep and pkill. And use code formatting.

            – grooveplex
            Jul 7 '16 at 20:03











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f796118%2fclosing-a-specific-terminal%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Njap



          The easy way: Create a variable that the while loop tests for true (or false, whatever way you like) and change this var to end the loop.



          The complicated way:
          Get the Pid of you Shell:



          $ echo $$


          returns e.g.



          1441


          The Shell (e.g. bash) runs in the Terminal, so the Terminal is identified by bashs parent PID. Get ppid:



          $ cat /proc/1441/status | grep PPid


          returns e.g.



          1432


          If you can Pid it, you can kill it. ;)



          $ kill 1432


          EDIT: There might be easier ways to get the Pid of the program process, e.g. if the program has a specific name, you can



          $ ps aux | grep nameofmyspecificprogram



          for it.






          share|improve this answer


























          • Use pgrep and pkill. And use code formatting.

            – grooveplex
            Jul 7 '16 at 20:03
















          1














          Njap



          The easy way: Create a variable that the while loop tests for true (or false, whatever way you like) and change this var to end the loop.



          The complicated way:
          Get the Pid of you Shell:



          $ echo $$


          returns e.g.



          1441


          The Shell (e.g. bash) runs in the Terminal, so the Terminal is identified by bashs parent PID. Get ppid:



          $ cat /proc/1441/status | grep PPid


          returns e.g.



          1432


          If you can Pid it, you can kill it. ;)



          $ kill 1432


          EDIT: There might be easier ways to get the Pid of the program process, e.g. if the program has a specific name, you can



          $ ps aux | grep nameofmyspecificprogram



          for it.






          share|improve this answer


























          • Use pgrep and pkill. And use code formatting.

            – grooveplex
            Jul 7 '16 at 20:03














          1












          1








          1







          Njap



          The easy way: Create a variable that the while loop tests for true (or false, whatever way you like) and change this var to end the loop.



          The complicated way:
          Get the Pid of you Shell:



          $ echo $$


          returns e.g.



          1441


          The Shell (e.g. bash) runs in the Terminal, so the Terminal is identified by bashs parent PID. Get ppid:



          $ cat /proc/1441/status | grep PPid


          returns e.g.



          1432


          If you can Pid it, you can kill it. ;)



          $ kill 1432


          EDIT: There might be easier ways to get the Pid of the program process, e.g. if the program has a specific name, you can



          $ ps aux | grep nameofmyspecificprogram



          for it.






          share|improve this answer















          Njap



          The easy way: Create a variable that the while loop tests for true (or false, whatever way you like) and change this var to end the loop.



          The complicated way:
          Get the Pid of you Shell:



          $ echo $$


          returns e.g.



          1441


          The Shell (e.g. bash) runs in the Terminal, so the Terminal is identified by bashs parent PID. Get ppid:



          $ cat /proc/1441/status | grep PPid


          returns e.g.



          1432


          If you can Pid it, you can kill it. ;)



          $ kill 1432


          EDIT: There might be easier ways to get the Pid of the program process, e.g. if the program has a specific name, you can



          $ ps aux | grep nameofmyspecificprogram



          for it.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 9 at 12:34









          Kulfy

          4,89151743




          4,89151743










          answered Jul 7 '16 at 19:59









          Lord_PedantenSteinLord_PedantenStein

          36216




          36216













          • Use pgrep and pkill. And use code formatting.

            – grooveplex
            Jul 7 '16 at 20:03



















          • Use pgrep and pkill. And use code formatting.

            – grooveplex
            Jul 7 '16 at 20:03

















          Use pgrep and pkill. And use code formatting.

          – grooveplex
          Jul 7 '16 at 20:03





          Use pgrep and pkill. And use code formatting.

          – grooveplex
          Jul 7 '16 at 20:03


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


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




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f796118%2fclosing-a-specific-terminal%23new-answer', 'question_page');
          }
          );

          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







          Popular posts from this blog

          How did Captain America manage to do this?

          迪纳利

          南乌拉尔铁路局