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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:34:36+00:00 2026-06-06T06:34:36+00:00

Possible Duplicate: Are file descriptors shared when fork()ing? Suppose I have following code in

  • 0

Possible Duplicate:
Are file descriptors shared when fork()ing?

Suppose I have following code in linux:

int main()
{
   FILE* f = fopen("file.txt", "w");
   fork();
   fwrite("A", 1, 1, f);
   fclose(f);
   return 0;
}

What I know about fork from documentation, is that it makes the copy of current process. It copies state of the memory as well, so *f should be equal in both instances. But what happens with system resources, such as a file handle? In this example I open the file with write intentions, so only one instance can write into file, right? Which of the instances will actually write into file? Who should care further about the file handle, and call fclose() ?

  • 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-06T06:34:38+00:00Added an answer on June 6, 2026 at 6:34 am

    Both processes get a handle. Both can write, but will share the current offset. Both should close, each closes its own handle.

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

Sidebar

Related Questions

Possible Duplicate: How to put exe file in windows Startup Suppose I have built
Possible Duplicate: Full path from file input using jQuery I have the following html
Possible Duplicate: Prepend lines to file in Java I have a CSV-file which supports
Possible Duplicate: HTML Compress File Upload? I have complains from client that my website
Possible Duplicate: Size of folder or file I used this code to instantiate a
Possible Duplicate: How to implement file upload progress bar on web? Hello I have
Possible Duplicate: include file from different directory I have a site laid out as
Possible Duplicate: PHP - send file to user I have written a script that
Possible Duplicate: Open a file in the proper encoding automatically my code: import csv
Possible Duplicate: Reading csv file I have a comma delimited file: Some Text, More

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.