πŸ“Š Linux
Q. If a program running in the background tries to read from STDIN
  • (A) Its execution is suspended
  • (B) STDIN is made available to him
  • (C) It completes its task
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) Its execution is suspended

Explanation: Background processes cannot read from the terminal. If they try, they are suspended by a SIGTTIN (teletype input) signal. The reason for this feature is that if multiple processes tried to read from the terminal, each character would essentially go randomly to one of the processes, which is not useful behavior. Thus, the foreground process gets the input and the background processes do not. If sudo tries to read from the terminal, to ask for your password, it is suspended. You must run sudo in the foreground, then switch to the background.

Explanation by: Mr. Dubey
Background processes cannot read from the terminal. If they try, they are suspended by a SIGTTIN (teletype input) signal. The reason for this feature is that if multiple processes tried to read from the terminal, each character would essentially go randomly to one of the processes, which is not useful behavior. Thus, the foreground process gets the input and the background processes do not. If sudo tries to read from the terminal, to ask for your password, it is suspended. You must run sudo in the foreground, then switch to the background.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
261
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
89%
Success Rate