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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:55:55+00:00 2026-06-02T01:55:55+00:00

If you do a fork() on a parent and create a child process, and

  • 0

If you do a fork() on a parent and create a child process, and then the child closes the fd (file descriptor) inherited from the fork (parent).

Would the file stay open in the parent, since they’re independent? What about standard i/o or stderr?

  • 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-06-02T01:55:57+00:00Added an answer on June 2, 2026 at 1:55 am

    Regardless of whether a file descriptor represents a file or a device, and regardless of whether it was ever passed as a standard i/o descriptor to any process: if you close it in one process, the other process still has a valid descriptor.

    (This is pretty natural. Imagine for a moment that the descriptor would be interdependent with the descriptor in the other process. Then, if a child process unexpectedly crashed, the parent process would have difficulty to even log this fact, once the crash was detected. It could not log the fact through any previously open descriptor, because all forms of process exit involve closing of all open descriptors. Failure modes would therefore tend to spread across processes. In addition, even regular, error free I/O patterns through such hypothetical shared descriptors would abound in race conditions.)

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

Sidebar

Related Questions

I would like to create a file whose descriptor would have some customizable behavior.
How would you, cleanly, get a parent process to create multiple children, where each
I know that fork() returns differently for the child and parent processes, but I'm
I've read about fork and from what I understand, the process is cloned but
I'm trying to create a two-way communication between parent and child processes using 2
On Unix, we can create a new process with fork(); execvp(argv[0], argv); (with a
I'm trying to spawn a new process from my C++-project using fork-exec. I'm using
As I understood fork() creates a child process by copying the image of the
I want to use shared memory to save characters printed by two parent-child process.
Why fork() before setsid() to daemonize a process? Basically, if I want to detach

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.