When a session leader acquires a controlling terminal, how would the other existing processes in the session also acquire the controlling terminal?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












Suppose there is a session with multiple processes in it and without a controlling terminal.



When the session leader creates a connection to a controlling terminal,



  • how would the other processes in the same session learn that the session has a controlling terminal and


  • how could they also make use of the controlling terminal?


The reason that I have this question is the following. Usually a process calls setsid() to start a new session and become its leader, and calls open() to connect to a controlling terminal. Then the session leader goes on to fork() child processes, and the children will inherit the file descriptor to the controlling terminal.



I then wonder what if a session already has multiple processes and but has no controlling terminal, and then the leader creates a connection to a controlling terminal, and then what about the other processes in the session.



Thanks.







share|improve this question























    up vote
    -1
    down vote

    favorite












    Suppose there is a session with multiple processes in it and without a controlling terminal.



    When the session leader creates a connection to a controlling terminal,



    • how would the other processes in the same session learn that the session has a controlling terminal and


    • how could they also make use of the controlling terminal?


    The reason that I have this question is the following. Usually a process calls setsid() to start a new session and become its leader, and calls open() to connect to a controlling terminal. Then the session leader goes on to fork() child processes, and the children will inherit the file descriptor to the controlling terminal.



    I then wonder what if a session already has multiple processes and but has no controlling terminal, and then the leader creates a connection to a controlling terminal, and then what about the other processes in the session.



    Thanks.







    share|improve this question





















      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      Suppose there is a session with multiple processes in it and without a controlling terminal.



      When the session leader creates a connection to a controlling terminal,



      • how would the other processes in the same session learn that the session has a controlling terminal and


      • how could they also make use of the controlling terminal?


      The reason that I have this question is the following. Usually a process calls setsid() to start a new session and become its leader, and calls open() to connect to a controlling terminal. Then the session leader goes on to fork() child processes, and the children will inherit the file descriptor to the controlling terminal.



      I then wonder what if a session already has multiple processes and but has no controlling terminal, and then the leader creates a connection to a controlling terminal, and then what about the other processes in the session.



      Thanks.







      share|improve this question











      Suppose there is a session with multiple processes in it and without a controlling terminal.



      When the session leader creates a connection to a controlling terminal,



      • how would the other processes in the same session learn that the session has a controlling terminal and


      • how could they also make use of the controlling terminal?


      The reason that I have this question is the following. Usually a process calls setsid() to start a new session and become its leader, and calls open() to connect to a controlling terminal. Then the session leader goes on to fork() child processes, and the children will inherit the file descriptor to the controlling terminal.



      I then wonder what if a session already has multiple processes and but has no controlling terminal, and then the leader creates a connection to a controlling terminal, and then what about the other processes in the session.



      Thanks.









      share|improve this question










      share|improve this question




      share|improve this question









      asked May 29 at 16:06









      Tim

      22.6k61222401




      22.6k61222401




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Any new child the session leader creates after it acquired a controlling terminal will also have that controlling terminal. A controlling terminal is something that is inherited from the parent.



          In other words: existing children are not affected.






          share|improve this answer























          • Thanks. But I was asking about the already existing children instead of any future children, when the leader acquires a controlling terminal.
            – Tim
            May 29 at 16:33










          • OK, I enhanced the answer.
            – schily
            May 29 at 16:50










          • Thanks. What do you mean by " existing children are not affected"? The other processes in the same session are not necessarily children of the session leader. How could the other processes learn that the session has a controlling terminal and also open the controlling terminal as a file descriptor?
            – Tim
            Jun 1 at 19:17











          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%2f446738%2fwhen-a-session-leader-acquires-a-controlling-terminal-how-would-the-other-exist%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
          0
          down vote













          Any new child the session leader creates after it acquired a controlling terminal will also have that controlling terminal. A controlling terminal is something that is inherited from the parent.



          In other words: existing children are not affected.






          share|improve this answer























          • Thanks. But I was asking about the already existing children instead of any future children, when the leader acquires a controlling terminal.
            – Tim
            May 29 at 16:33










          • OK, I enhanced the answer.
            – schily
            May 29 at 16:50










          • Thanks. What do you mean by " existing children are not affected"? The other processes in the same session are not necessarily children of the session leader. How could the other processes learn that the session has a controlling terminal and also open the controlling terminal as a file descriptor?
            – Tim
            Jun 1 at 19:17















          up vote
          0
          down vote













          Any new child the session leader creates after it acquired a controlling terminal will also have that controlling terminal. A controlling terminal is something that is inherited from the parent.



          In other words: existing children are not affected.






          share|improve this answer























          • Thanks. But I was asking about the already existing children instead of any future children, when the leader acquires a controlling terminal.
            – Tim
            May 29 at 16:33










          • OK, I enhanced the answer.
            – schily
            May 29 at 16:50










          • Thanks. What do you mean by " existing children are not affected"? The other processes in the same session are not necessarily children of the session leader. How could the other processes learn that the session has a controlling terminal and also open the controlling terminal as a file descriptor?
            – Tim
            Jun 1 at 19:17













          up vote
          0
          down vote










          up vote
          0
          down vote









          Any new child the session leader creates after it acquired a controlling terminal will also have that controlling terminal. A controlling terminal is something that is inherited from the parent.



          In other words: existing children are not affected.






          share|improve this answer















          Any new child the session leader creates after it acquired a controlling terminal will also have that controlling terminal. A controlling terminal is something that is inherited from the parent.



          In other words: existing children are not affected.







          share|improve this answer















          share|improve this answer



          share|improve this answer








          edited May 29 at 16:42


























          answered May 29 at 16:20









          schily

          8,63821435




          8,63821435











          • Thanks. But I was asking about the already existing children instead of any future children, when the leader acquires a controlling terminal.
            – Tim
            May 29 at 16:33










          • OK, I enhanced the answer.
            – schily
            May 29 at 16:50










          • Thanks. What do you mean by " existing children are not affected"? The other processes in the same session are not necessarily children of the session leader. How could the other processes learn that the session has a controlling terminal and also open the controlling terminal as a file descriptor?
            – Tim
            Jun 1 at 19:17

















          • Thanks. But I was asking about the already existing children instead of any future children, when the leader acquires a controlling terminal.
            – Tim
            May 29 at 16:33










          • OK, I enhanced the answer.
            – schily
            May 29 at 16:50










          • Thanks. What do you mean by " existing children are not affected"? The other processes in the same session are not necessarily children of the session leader. How could the other processes learn that the session has a controlling terminal and also open the controlling terminal as a file descriptor?
            – Tim
            Jun 1 at 19:17
















          Thanks. But I was asking about the already existing children instead of any future children, when the leader acquires a controlling terminal.
          – Tim
          May 29 at 16:33




          Thanks. But I was asking about the already existing children instead of any future children, when the leader acquires a controlling terminal.
          – Tim
          May 29 at 16:33












          OK, I enhanced the answer.
          – schily
          May 29 at 16:50




          OK, I enhanced the answer.
          – schily
          May 29 at 16:50












          Thanks. What do you mean by " existing children are not affected"? The other processes in the same session are not necessarily children of the session leader. How could the other processes learn that the session has a controlling terminal and also open the controlling terminal as a file descriptor?
          – Tim
          Jun 1 at 19:17





          Thanks. What do you mean by " existing children are not affected"? The other processes in the same session are not necessarily children of the session leader. How could the other processes learn that the session has a controlling terminal and also open the controlling terminal as a file descriptor?
          – Tim
          Jun 1 at 19:17













           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f446738%2fwhen-a-session-leader-acquires-a-controlling-terminal-how-would-the-other-exist%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?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?