Running a pseudoterminal inside a pseudoterminal

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











up vote
2
down vote

favorite












I'm trying to understand how the programs like screen and script control I/O.



My knowledge of terminal, tty etc. comes from reading the 'tty demystified' article, and all the SE answers I could find. So from what I understand, roughly the interactions between components work as follows:



Console(Keyboard+Screen) ---- xterm(pty master) ----- tty line discipline ---- bash/other programs(pty slave)



where the line discipline is in the kernel, and xterm and bash run in the userspace.



  1. Is this correct?

Now, when we consider programs like screen, script, they are userspace programs that run in a terminal(the existing xterm), yet are able to control I/O to/from other programs. The article mentions that this is becuase they run another pseudoterminal inside xterm(the existing pseudoterminal).



  1. Does that mean that they open up a new pty master - slave pair, control the master end of this new pair, and all the processes launched from them run on the new pty slave? For example each time I start a new 'screen', and run the tty command, it shows me a diffrent /dev/pts/x. Does script also run in a similar way?


  2. Finally can somebody point me to any article/book where I can get a little more detail on this stuff(Haven't been able to find anything)?


I'd also like to reference this answer, though it is very brief.







share|improve this question


























    up vote
    2
    down vote

    favorite












    I'm trying to understand how the programs like screen and script control I/O.



    My knowledge of terminal, tty etc. comes from reading the 'tty demystified' article, and all the SE answers I could find. So from what I understand, roughly the interactions between components work as follows:



    Console(Keyboard+Screen) ---- xterm(pty master) ----- tty line discipline ---- bash/other programs(pty slave)



    where the line discipline is in the kernel, and xterm and bash run in the userspace.



    1. Is this correct?

    Now, when we consider programs like screen, script, they are userspace programs that run in a terminal(the existing xterm), yet are able to control I/O to/from other programs. The article mentions that this is becuase they run another pseudoterminal inside xterm(the existing pseudoterminal).



    1. Does that mean that they open up a new pty master - slave pair, control the master end of this new pair, and all the processes launched from them run on the new pty slave? For example each time I start a new 'screen', and run the tty command, it shows me a diffrent /dev/pts/x. Does script also run in a similar way?


    2. Finally can somebody point me to any article/book where I can get a little more detail on this stuff(Haven't been able to find anything)?


    I'd also like to reference this answer, though it is very brief.







    share|improve this question
























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I'm trying to understand how the programs like screen and script control I/O.



      My knowledge of terminal, tty etc. comes from reading the 'tty demystified' article, and all the SE answers I could find. So from what I understand, roughly the interactions between components work as follows:



      Console(Keyboard+Screen) ---- xterm(pty master) ----- tty line discipline ---- bash/other programs(pty slave)



      where the line discipline is in the kernel, and xterm and bash run in the userspace.



      1. Is this correct?

      Now, when we consider programs like screen, script, they are userspace programs that run in a terminal(the existing xterm), yet are able to control I/O to/from other programs. The article mentions that this is becuase they run another pseudoterminal inside xterm(the existing pseudoterminal).



      1. Does that mean that they open up a new pty master - slave pair, control the master end of this new pair, and all the processes launched from them run on the new pty slave? For example each time I start a new 'screen', and run the tty command, it shows me a diffrent /dev/pts/x. Does script also run in a similar way?


      2. Finally can somebody point me to any article/book where I can get a little more detail on this stuff(Haven't been able to find anything)?


      I'd also like to reference this answer, though it is very brief.







      share|improve this question














      I'm trying to understand how the programs like screen and script control I/O.



      My knowledge of terminal, tty etc. comes from reading the 'tty demystified' article, and all the SE answers I could find. So from what I understand, roughly the interactions between components work as follows:



      Console(Keyboard+Screen) ---- xterm(pty master) ----- tty line discipline ---- bash/other programs(pty slave)



      where the line discipline is in the kernel, and xterm and bash run in the userspace.



      1. Is this correct?

      Now, when we consider programs like screen, script, they are userspace programs that run in a terminal(the existing xterm), yet are able to control I/O to/from other programs. The article mentions that this is becuase they run another pseudoterminal inside xterm(the existing pseudoterminal).



      1. Does that mean that they open up a new pty master - slave pair, control the master end of this new pair, and all the processes launched from them run on the new pty slave? For example each time I start a new 'screen', and run the tty command, it shows me a diffrent /dev/pts/x. Does script also run in a similar way?


      2. Finally can somebody point me to any article/book where I can get a little more detail on this stuff(Haven't been able to find anything)?


      I'd also like to reference this answer, though it is very brief.









      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 3 at 16:24

























      asked Jan 3 at 16:14









      forumulator

      1285




      1285




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          ① Yes, xterm and bash run in userspace. As do screen and script.



          ② Yep, that's correct. Screen basically is a terminal emulator, just like XTerm. Except of course XTerm outputs commands to the X11 server to display the terminal, whereas screen outputs control sequences & text to a another terminal (which can be a terminal emulator or an actual terminal).



          ③ The best detail on how those programs work is probably the source code. Questions about them are welcome here, of course, or code questions are welcome on Stack Overflow.






          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%2f414579%2frunning-a-pseudoterminal-inside-a-pseudoterminal%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
            2
            down vote



            accepted










            ① Yes, xterm and bash run in userspace. As do screen and script.



            ② Yep, that's correct. Screen basically is a terminal emulator, just like XTerm. Except of course XTerm outputs commands to the X11 server to display the terminal, whereas screen outputs control sequences & text to a another terminal (which can be a terminal emulator or an actual terminal).



            ③ The best detail on how those programs work is probably the source code. Questions about them are welcome here, of course, or code questions are welcome on Stack Overflow.






            share|improve this answer
























              up vote
              2
              down vote



              accepted










              ① Yes, xterm and bash run in userspace. As do screen and script.



              ② Yep, that's correct. Screen basically is a terminal emulator, just like XTerm. Except of course XTerm outputs commands to the X11 server to display the terminal, whereas screen outputs control sequences & text to a another terminal (which can be a terminal emulator or an actual terminal).



              ③ The best detail on how those programs work is probably the source code. Questions about them are welcome here, of course, or code questions are welcome on Stack Overflow.






              share|improve this answer






















                up vote
                2
                down vote



                accepted







                up vote
                2
                down vote



                accepted






                ① Yes, xterm and bash run in userspace. As do screen and script.



                ② Yep, that's correct. Screen basically is a terminal emulator, just like XTerm. Except of course XTerm outputs commands to the X11 server to display the terminal, whereas screen outputs control sequences & text to a another terminal (which can be a terminal emulator or an actual terminal).



                ③ The best detail on how those programs work is probably the source code. Questions about them are welcome here, of course, or code questions are welcome on Stack Overflow.






                share|improve this answer












                ① Yes, xterm and bash run in userspace. As do screen and script.



                ② Yep, that's correct. Screen basically is a terminal emulator, just like XTerm. Except of course XTerm outputs commands to the X11 server to display the terminal, whereas screen outputs control sequences & text to a another terminal (which can be a terminal emulator or an actual terminal).



                ③ The best detail on how those programs work is probably the source code. Questions about them are welcome here, of course, or code questions are welcome on Stack Overflow.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 3 at 16:25









                derobert

                68.7k8148203




                68.7k8148203






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f414579%2frunning-a-pseudoterminal-inside-a-pseudoterminal%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?