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 1099679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:46:09+00:00 2026-05-17T00:46:09+00:00

I have a question in mind. By convention, unix associates the file descriptor 0,

  • 0

I have a question in mind. By convention, unix associates the file descriptor 0, 1, 2 for stdin, stdout, stderr on every process. Is the file, e.g. pointed by stdin, shared by different processes? If shared, when we open two shells to type some inputs to these two shells, how is the os doing to manage the shared file?

  • 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-17T00:46:10+00:00Added an answer on May 17, 2026 at 12:46 am

    Overview

    The descriptor table is per-process, so it’s possible for every process in the system to have a different file open in every descriptor table slot

    But in practice it’s a bit more complex. If two processes open a file independently, then they each have completely separate access to the file, with their own read and write pointers, and they will only interact if they both write to the same file.

    But when a process fork(2)’s, then the parent and child’s descriptors point to the same file table entry, and so they share a single position in the file. This enables Unix processes to share access to an input stream without needing to be aware of the situation.

    Three Tables

    Access to files is chained through three important tables in Unix. The descriptor table is per-process and points to the file table. Think of the file table as the open file table. There is a third table, originally called the inode table that manages access to actual files.

    The key thing to realize is that while there is never more than one entry in the inode table for any one file, there may or may not be multiple entries in the file table. If a file descriptor is created with open(2) then the inode gets a new file table entry, but if it’s created with fork(2) then the same file table entry is reused and the read and write pointers are shared.

    So, two shells…

    In the case of two shells with two different windows for typing, or two shells running different scripts, then they aren’t using the same file at all, or if it’s the same script, it was opened twice so their positions are independent. Both may be file descriptor “0” within each process but that’s because every process has its own descriptor table.

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

Sidebar

Related Questions

I am new to db4o . I have this question in mind: when the
As a huge fan of C++, there have been a question in my mind.
I have this little question that's been on my mind for a while now.
I have a really dumb question if you don't mind me to ask :(
I have a specific case in mind, but the question applies in general too.
I have raise one question in my mind that Why we are frequently use
I have one question in my mind that can we test the in-app purchase
I have a question in my mind from last many days, that while writing
I have a question which is bounching in my mind since a long long
I have question about parsing in Html helper : I have sth like: @foreach

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.