When will login terminate?

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











up vote
0
down vote

favorite












When starting up an OS, getty and login are run. It seems that login will continuously run after finish logging in.



There is no logout command. I wonder when login will terminate running, except when shut down the OS?



Btw, is it correct that login only runs on text console, not when starting X windows and a display manager and a desktop environment?



Thanks.







share|improve this question



















  • See also unix.stackexchange.com/questions/194197 and unix.stackexchange.com/questions/255385.
    – JdeBP
    May 4 at 23:54















up vote
0
down vote

favorite












When starting up an OS, getty and login are run. It seems that login will continuously run after finish logging in.



There is no logout command. I wonder when login will terminate running, except when shut down the OS?



Btw, is it correct that login only runs on text console, not when starting X windows and a display manager and a desktop environment?



Thanks.







share|improve this question



















  • See also unix.stackexchange.com/questions/194197 and unix.stackexchange.com/questions/255385.
    – JdeBP
    May 4 at 23:54













up vote
0
down vote

favorite









up vote
0
down vote

favorite











When starting up an OS, getty and login are run. It seems that login will continuously run after finish logging in.



There is no logout command. I wonder when login will terminate running, except when shut down the OS?



Btw, is it correct that login only runs on text console, not when starting X windows and a display manager and a desktop environment?



Thanks.







share|improve this question











When starting up an OS, getty and login are run. It seems that login will continuously run after finish logging in.



There is no logout command. I wonder when login will terminate running, except when shut down the OS?



Btw, is it correct that login only runs on text console, not when starting X windows and a display manager and a desktop environment?



Thanks.









share|improve this question










share|improve this question




share|improve this question









asked May 3 at 23:58









Tim

22.6k63223401




22.6k63223401











  • See also unix.stackexchange.com/questions/194197 and unix.stackexchange.com/questions/255385.
    – JdeBP
    May 4 at 23:54

















  • See also unix.stackexchange.com/questions/194197 and unix.stackexchange.com/questions/255385.
    – JdeBP
    May 4 at 23:54
















See also unix.stackexchange.com/questions/194197 and unix.stackexchange.com/questions/255385.
– JdeBP
May 4 at 23:54





See also unix.stackexchange.com/questions/194197 and unix.stackexchange.com/questions/255385.
– JdeBP
May 4 at 23:54











1 Answer
1






active

oldest

votes

















up vote
5
down vote













login terminates when its child (the logged-in user’s login shell) terminates. It could even exec the child without forking, replacing itself, but it needs to take care of PAM session clean-up, so it has to wait for its child instead. Once it terminates, getty or init (more generally, the init process) do some more clean-up (utmp etc.) and wait for a new login (if getty replaced itself with login, or exits when login terminates, the init process will start a new getty).



You’re right, under Linux at least, login is generally only used on virtual consoles (or real terminals connected via serial devices). Graphical display managers implement their own login mechanisms. You can run login inside a login shell, e.g. in a terminal emulator, with a little care (exec login); a long time ago, recursive login was used to change users, the equivalent of su nowadays.



Note that some shells do have a logout command, which is supposed to be used instead of exit to exit a login shell; in such shells, exit typically won’t exit from a login shell.






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%2f441678%2fwhen-will-login-terminate%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
    5
    down vote













    login terminates when its child (the logged-in user’s login shell) terminates. It could even exec the child without forking, replacing itself, but it needs to take care of PAM session clean-up, so it has to wait for its child instead. Once it terminates, getty or init (more generally, the init process) do some more clean-up (utmp etc.) and wait for a new login (if getty replaced itself with login, or exits when login terminates, the init process will start a new getty).



    You’re right, under Linux at least, login is generally only used on virtual consoles (or real terminals connected via serial devices). Graphical display managers implement their own login mechanisms. You can run login inside a login shell, e.g. in a terminal emulator, with a little care (exec login); a long time ago, recursive login was used to change users, the equivalent of su nowadays.



    Note that some shells do have a logout command, which is supposed to be used instead of exit to exit a login shell; in such shells, exit typically won’t exit from a login shell.






    share|improve this answer



























      up vote
      5
      down vote













      login terminates when its child (the logged-in user’s login shell) terminates. It could even exec the child without forking, replacing itself, but it needs to take care of PAM session clean-up, so it has to wait for its child instead. Once it terminates, getty or init (more generally, the init process) do some more clean-up (utmp etc.) and wait for a new login (if getty replaced itself with login, or exits when login terminates, the init process will start a new getty).



      You’re right, under Linux at least, login is generally only used on virtual consoles (or real terminals connected via serial devices). Graphical display managers implement their own login mechanisms. You can run login inside a login shell, e.g. in a terminal emulator, with a little care (exec login); a long time ago, recursive login was used to change users, the equivalent of su nowadays.



      Note that some shells do have a logout command, which is supposed to be used instead of exit to exit a login shell; in such shells, exit typically won’t exit from a login shell.






      share|improve this answer

























        up vote
        5
        down vote










        up vote
        5
        down vote









        login terminates when its child (the logged-in user’s login shell) terminates. It could even exec the child without forking, replacing itself, but it needs to take care of PAM session clean-up, so it has to wait for its child instead. Once it terminates, getty or init (more generally, the init process) do some more clean-up (utmp etc.) and wait for a new login (if getty replaced itself with login, or exits when login terminates, the init process will start a new getty).



        You’re right, under Linux at least, login is generally only used on virtual consoles (or real terminals connected via serial devices). Graphical display managers implement their own login mechanisms. You can run login inside a login shell, e.g. in a terminal emulator, with a little care (exec login); a long time ago, recursive login was used to change users, the equivalent of su nowadays.



        Note that some shells do have a logout command, which is supposed to be used instead of exit to exit a login shell; in such shells, exit typically won’t exit from a login shell.






        share|improve this answer















        login terminates when its child (the logged-in user’s login shell) terminates. It could even exec the child without forking, replacing itself, but it needs to take care of PAM session clean-up, so it has to wait for its child instead. Once it terminates, getty or init (more generally, the init process) do some more clean-up (utmp etc.) and wait for a new login (if getty replaced itself with login, or exits when login terminates, the init process will start a new getty).



        You’re right, under Linux at least, login is generally only used on virtual consoles (or real terminals connected via serial devices). Graphical display managers implement their own login mechanisms. You can run login inside a login shell, e.g. in a terminal emulator, with a little care (exec login); a long time ago, recursive login was used to change users, the equivalent of su nowadays.



        Note that some shells do have a logout command, which is supposed to be used instead of exit to exit a login shell; in such shells, exit typically won’t exit from a login shell.







        share|improve this answer















        share|improve this answer



        share|improve this answer








        edited May 4 at 17:33









        JdeBP

        28.1k459133




        28.1k459133











        answered May 4 at 5:18









        Stephen Kitt

        140k22302363




        140k22302363






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f441678%2fwhen-will-login-terminate%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)