Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4602086
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:55:40+00:00 2026-05-21T23:55:40+00:00

I guess I’m not clear on what what the function of the getty/agetty/mgetty programs

  • 0

I guess I’m not clear on what what the function of the getty/agetty/mgetty programs are on a linux/unix machine. I can start a shell on a tty with something like this:

TTY = '/dev/tty3'

cpid = os.fork()
if cpid == 0:
    os.closerange(0, 4)
    sys.stdin = open(TTY, 'r')
    sys.stdout = open(TTY, 'w')
    sys.stderr = open(TTY, 'w')
    os.execv(('/bin/bash',), ('bash',))

..and if i switch over to tty3, there is a shell running- but some keystrokes are ignored / are never being sent to the shell. the shell knows the TTY settings are not correct because bash will say something like ‘unable to open tty, job control disabled’

I know the ‘termios’ module has functions to change the settings on the TTY, which is what the ‘tty’ module uses, but i am unable to find an example of python setting the TTY correctly and starting a shell. I feel like it should be something simple, but i don’t know where to look.

looking at the source for the *etty programs didn’t help me- C looks like greek to me :-/

Maybe im just not looking for the right terms? Anyone replaced the *etty programs with Python in the past and have an explanation they would care to share?

Thanks for entertaining my basic question 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T23:55:41+00:00Added an answer on May 21, 2026 at 11:55 pm

    I can see at least two things you’re missing – there may be more:

    Firstly, you need to call setsid() in the child process after closing the old standard input/standard output, and before opening the new TTY. This does two important things – it makes your new process the leader of a new session, and it disassociates it from its previous controlling terminal (merely closing that terminal is not sufficient). This will mean that when you open the new tty, it will become the controlling terminal, which is what you want.

    Secondly, you need to set the TERM environment variable to match the new tty.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I guess I'm not clear on how to do and tests. I wanted to
I guess the problem is that I do not know how to use factory
I guess with what I'm going to write I should first clarify, it's not
I guess I've seen it somewhere before, but now I can't remember nor find
I guess it's not so hard to do this by hand, but I was
I guess not as this is not working: <!DOCTYPE html> <html> <head> <meta charset=utf-8
I guess it's a simple question, but how can I replace nil values in
I guess I have an easy question, I have not found the right answer
I guess I'm not sending the data required by the API correctly. Any ideas
I guess I don't give title nicely, anyways, I can explain it better here:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.