Is it the process that has a controlling terminal, or is it the session that has a controlling terminal?

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











up vote
5
down vote

favorite












When we say that a process has a controlling terminal, do we mean that the process itself has a controlling terminal, or is it the session that the process belongs to that has a controlling terminal?



I used to think that it is the session that has a controlling terminal, but then I have read the following (from here) which implies that it is the process that has a controlling terminal:




One of the attributes of a process is its controlling terminal. Child
processes created with fork inherit the controlling terminal from
their parent process. In this way, all the processes in a session
inherit the controlling terminal from the session leader. A session
leader that has control of a terminal is called the controlling
process of that terminal.








share|improve this question
















  • 1




    Read The tty demystified page.
    – Basile Starynkevitch
    Nov 20 '17 at 12:12










  • Bam.... see if this helps clarify any too.... poincare.matf.bg.ac.rs/~ivana/courses/ps/sistemi_knjige/pomocno/…
    – Facebook
    Nov 20 '17 at 12:22














up vote
5
down vote

favorite












When we say that a process has a controlling terminal, do we mean that the process itself has a controlling terminal, or is it the session that the process belongs to that has a controlling terminal?



I used to think that it is the session that has a controlling terminal, but then I have read the following (from here) which implies that it is the process that has a controlling terminal:




One of the attributes of a process is its controlling terminal. Child
processes created with fork inherit the controlling terminal from
their parent process. In this way, all the processes in a session
inherit the controlling terminal from the session leader. A session
leader that has control of a terminal is called the controlling
process of that terminal.








share|improve this question
















  • 1




    Read The tty demystified page.
    – Basile Starynkevitch
    Nov 20 '17 at 12:12










  • Bam.... see if this helps clarify any too.... poincare.matf.bg.ac.rs/~ivana/courses/ps/sistemi_knjige/pomocno/…
    – Facebook
    Nov 20 '17 at 12:22












up vote
5
down vote

favorite









up vote
5
down vote

favorite











When we say that a process has a controlling terminal, do we mean that the process itself has a controlling terminal, or is it the session that the process belongs to that has a controlling terminal?



I used to think that it is the session that has a controlling terminal, but then I have read the following (from here) which implies that it is the process that has a controlling terminal:




One of the attributes of a process is its controlling terminal. Child
processes created with fork inherit the controlling terminal from
their parent process. In this way, all the processes in a session
inherit the controlling terminal from the session leader. A session
leader that has control of a terminal is called the controlling
process of that terminal.








share|improve this question












When we say that a process has a controlling terminal, do we mean that the process itself has a controlling terminal, or is it the session that the process belongs to that has a controlling terminal?



I used to think that it is the session that has a controlling terminal, but then I have read the following (from here) which implies that it is the process that has a controlling terminal:




One of the attributes of a process is its controlling terminal. Child
processes created with fork inherit the controlling terminal from
their parent process. In this way, all the processes in a session
inherit the controlling terminal from the session leader. A session
leader that has control of a terminal is called the controlling
process of that terminal.










share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '17 at 12:10









Joseph

1075




1075







  • 1




    Read The tty demystified page.
    – Basile Starynkevitch
    Nov 20 '17 at 12:12










  • Bam.... see if this helps clarify any too.... poincare.matf.bg.ac.rs/~ivana/courses/ps/sistemi_knjige/pomocno/…
    – Facebook
    Nov 20 '17 at 12:22












  • 1




    Read The tty demystified page.
    – Basile Starynkevitch
    Nov 20 '17 at 12:12










  • Bam.... see if this helps clarify any too.... poincare.matf.bg.ac.rs/~ivana/courses/ps/sistemi_knjige/pomocno/…
    – Facebook
    Nov 20 '17 at 12:22







1




1




Read The tty demystified page.
– Basile Starynkevitch
Nov 20 '17 at 12:12




Read The tty demystified page.
– Basile Starynkevitch
Nov 20 '17 at 12:12












Bam.... see if this helps clarify any too.... poincare.matf.bg.ac.rs/~ivana/courses/ps/sistemi_knjige/pomocno/…
– Facebook
Nov 20 '17 at 12:22




Bam.... see if this helps clarify any too.... poincare.matf.bg.ac.rs/~ivana/courses/ps/sistemi_knjige/pomocno/…
– Facebook
Nov 20 '17 at 12:22










1 Answer
1






active

oldest

votes

















up vote
6
down vote



accepted










It is indeed the session.



The Single UNIX Specification describes the relationship in terms of the controlling terminal being "associated with a session". As it goes on to specify, a controlling terminal has a 1:1 relationship with a session. There is "at most one controlling terminal" associated with a session, and "a controlling terminal is associated with exactly one session".



The FreeBSD Design and Implementation book approaches this slightly differently, but reaches the same place. It is not possible for processes that share the same session to have different controlling terminals, nor is it possible for a single terminal to be the controlling terminal of multiple sessions.



Internally in FreeBSD that is how the data structures actually work. The process structure has a pointer to the pgrp structure representing the process group that the process belongs to, which in turn points to the session structure representing the session that the process group belongs to, which in turn points to the tty structure of the controlling terminal for the session.



Internally in Linux, things are slightly more complex. Each task_struct has a set of pointers to pid structures for its process group ID and session ID; and has another pointer to a per-process signal_struct structure that in turn directly points to the tty structure of the controlling terminal.



Further reading



  • George V. Neville-Neil, Marshall Kirk McKusick, and Robert N.M. Watson (2014-09-25). "Process Management". The Design and Implementation of the FreeBSD Operating System. Addison-Wesley Professional. ISBN 9780133761832.

  • Donald Lewine (1991). "Terminal I/O". POSIX Programmers Guide. O'Reilly Media, Inc. ISBN 9780937175736.

  • Daniel P. Bovet and Marco Cesati (2005). "Processes". Understanding the Linux Kernel: From I/O Ports to Process Management. 3rd edition. O'Reilly Media, Inc. ISBN 9780596554910.

  • "Definitions". The Open Group Base Specifications. Issue 7. 2016. IEEE 1003.1:2008.

  • "General Terminal Interface". The Open Group Base Specifications. Issue 7. 2016. IEEE 1003.1:2008.





share|improve this answer




















    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%2f405755%2fis-it-the-process-that-has-a-controlling-terminal-or-is-it-the-session-that-has%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
    6
    down vote



    accepted










    It is indeed the session.



    The Single UNIX Specification describes the relationship in terms of the controlling terminal being "associated with a session". As it goes on to specify, a controlling terminal has a 1:1 relationship with a session. There is "at most one controlling terminal" associated with a session, and "a controlling terminal is associated with exactly one session".



    The FreeBSD Design and Implementation book approaches this slightly differently, but reaches the same place. It is not possible for processes that share the same session to have different controlling terminals, nor is it possible for a single terminal to be the controlling terminal of multiple sessions.



    Internally in FreeBSD that is how the data structures actually work. The process structure has a pointer to the pgrp structure representing the process group that the process belongs to, which in turn points to the session structure representing the session that the process group belongs to, which in turn points to the tty structure of the controlling terminal for the session.



    Internally in Linux, things are slightly more complex. Each task_struct has a set of pointers to pid structures for its process group ID and session ID; and has another pointer to a per-process signal_struct structure that in turn directly points to the tty structure of the controlling terminal.



    Further reading



    • George V. Neville-Neil, Marshall Kirk McKusick, and Robert N.M. Watson (2014-09-25). "Process Management". The Design and Implementation of the FreeBSD Operating System. Addison-Wesley Professional. ISBN 9780133761832.

    • Donald Lewine (1991). "Terminal I/O". POSIX Programmers Guide. O'Reilly Media, Inc. ISBN 9780937175736.

    • Daniel P. Bovet and Marco Cesati (2005). "Processes". Understanding the Linux Kernel: From I/O Ports to Process Management. 3rd edition. O'Reilly Media, Inc. ISBN 9780596554910.

    • "Definitions". The Open Group Base Specifications. Issue 7. 2016. IEEE 1003.1:2008.

    • "General Terminal Interface". The Open Group Base Specifications. Issue 7. 2016. IEEE 1003.1:2008.





    share|improve this answer
























      up vote
      6
      down vote



      accepted










      It is indeed the session.



      The Single UNIX Specification describes the relationship in terms of the controlling terminal being "associated with a session". As it goes on to specify, a controlling terminal has a 1:1 relationship with a session. There is "at most one controlling terminal" associated with a session, and "a controlling terminal is associated with exactly one session".



      The FreeBSD Design and Implementation book approaches this slightly differently, but reaches the same place. It is not possible for processes that share the same session to have different controlling terminals, nor is it possible for a single terminal to be the controlling terminal of multiple sessions.



      Internally in FreeBSD that is how the data structures actually work. The process structure has a pointer to the pgrp structure representing the process group that the process belongs to, which in turn points to the session structure representing the session that the process group belongs to, which in turn points to the tty structure of the controlling terminal for the session.



      Internally in Linux, things are slightly more complex. Each task_struct has a set of pointers to pid structures for its process group ID and session ID; and has another pointer to a per-process signal_struct structure that in turn directly points to the tty structure of the controlling terminal.



      Further reading



      • George V. Neville-Neil, Marshall Kirk McKusick, and Robert N.M. Watson (2014-09-25). "Process Management". The Design and Implementation of the FreeBSD Operating System. Addison-Wesley Professional. ISBN 9780133761832.

      • Donald Lewine (1991). "Terminal I/O". POSIX Programmers Guide. O'Reilly Media, Inc. ISBN 9780937175736.

      • Daniel P. Bovet and Marco Cesati (2005). "Processes". Understanding the Linux Kernel: From I/O Ports to Process Management. 3rd edition. O'Reilly Media, Inc. ISBN 9780596554910.

      • "Definitions". The Open Group Base Specifications. Issue 7. 2016. IEEE 1003.1:2008.

      • "General Terminal Interface". The Open Group Base Specifications. Issue 7. 2016. IEEE 1003.1:2008.





      share|improve this answer






















        up vote
        6
        down vote



        accepted







        up vote
        6
        down vote



        accepted






        It is indeed the session.



        The Single UNIX Specification describes the relationship in terms of the controlling terminal being "associated with a session". As it goes on to specify, a controlling terminal has a 1:1 relationship with a session. There is "at most one controlling terminal" associated with a session, and "a controlling terminal is associated with exactly one session".



        The FreeBSD Design and Implementation book approaches this slightly differently, but reaches the same place. It is not possible for processes that share the same session to have different controlling terminals, nor is it possible for a single terminal to be the controlling terminal of multiple sessions.



        Internally in FreeBSD that is how the data structures actually work. The process structure has a pointer to the pgrp structure representing the process group that the process belongs to, which in turn points to the session structure representing the session that the process group belongs to, which in turn points to the tty structure of the controlling terminal for the session.



        Internally in Linux, things are slightly more complex. Each task_struct has a set of pointers to pid structures for its process group ID and session ID; and has another pointer to a per-process signal_struct structure that in turn directly points to the tty structure of the controlling terminal.



        Further reading



        • George V. Neville-Neil, Marshall Kirk McKusick, and Robert N.M. Watson (2014-09-25). "Process Management". The Design and Implementation of the FreeBSD Operating System. Addison-Wesley Professional. ISBN 9780133761832.

        • Donald Lewine (1991). "Terminal I/O". POSIX Programmers Guide. O'Reilly Media, Inc. ISBN 9780937175736.

        • Daniel P. Bovet and Marco Cesati (2005). "Processes". Understanding the Linux Kernel: From I/O Ports to Process Management. 3rd edition. O'Reilly Media, Inc. ISBN 9780596554910.

        • "Definitions". The Open Group Base Specifications. Issue 7. 2016. IEEE 1003.1:2008.

        • "General Terminal Interface". The Open Group Base Specifications. Issue 7. 2016. IEEE 1003.1:2008.





        share|improve this answer












        It is indeed the session.



        The Single UNIX Specification describes the relationship in terms of the controlling terminal being "associated with a session". As it goes on to specify, a controlling terminal has a 1:1 relationship with a session. There is "at most one controlling terminal" associated with a session, and "a controlling terminal is associated with exactly one session".



        The FreeBSD Design and Implementation book approaches this slightly differently, but reaches the same place. It is not possible for processes that share the same session to have different controlling terminals, nor is it possible for a single terminal to be the controlling terminal of multiple sessions.



        Internally in FreeBSD that is how the data structures actually work. The process structure has a pointer to the pgrp structure representing the process group that the process belongs to, which in turn points to the session structure representing the session that the process group belongs to, which in turn points to the tty structure of the controlling terminal for the session.



        Internally in Linux, things are slightly more complex. Each task_struct has a set of pointers to pid structures for its process group ID and session ID; and has another pointer to a per-process signal_struct structure that in turn directly points to the tty structure of the controlling terminal.



        Further reading



        • George V. Neville-Neil, Marshall Kirk McKusick, and Robert N.M. Watson (2014-09-25). "Process Management". The Design and Implementation of the FreeBSD Operating System. Addison-Wesley Professional. ISBN 9780133761832.

        • Donald Lewine (1991). "Terminal I/O". POSIX Programmers Guide. O'Reilly Media, Inc. ISBN 9780937175736.

        • Daniel P. Bovet and Marco Cesati (2005). "Processes". Understanding the Linux Kernel: From I/O Ports to Process Management. 3rd edition. O'Reilly Media, Inc. ISBN 9780596554910.

        • "Definitions". The Open Group Base Specifications. Issue 7. 2016. IEEE 1003.1:2008.

        • "General Terminal Interface". The Open Group Base Specifications. Issue 7. 2016. IEEE 1003.1:2008.






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 '17 at 14:01









        JdeBP

        29k459135




        29k459135



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f405755%2fis-it-the-process-that-has-a-controlling-terminal-or-is-it-the-session-that-has%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?