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

  • Home
  • SEARCH
  • 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 7659945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:23:59+00:00 2026-05-31T13:23:59+00:00

Possible Duplicate: Unix fork() system call what runs when? I looked on Wikipedia, and

  • 0

Possible Duplicate:
Unix fork() system call what runs when?

I looked on Wikipedia, and the article said, “The purpose of fork() system call is to create a new process, which becomes the child process of caller, after which both, the parent and child processes, will execute the code following the fork() system call. Hence, it is important to distinguish between parent and child process. This can be done by testing the return value of fork() system call.”

In that case, what does this code execute:

printf("This is a fork!");
fork();

Given the description, it looks like it will say “This is a fork!” just once, since nothing lies AFTER the fork() statement. However, when I tested this out on a linux box, it printed “This is a fork!” twice. So which is it?

Thanks.

  • 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-31T13:24:00+00:00Added an answer on May 31, 2026 at 1:24 pm

    The output of printf is buffered; both child processes got a copy of the buffer; the buffer was flushed twice when each child process exited.

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

Sidebar

Related Questions

Possible Duplicate: what is the purpose of atexit function? In UNIX at least: I'm
Possible Duplicate: Delphi XE2: Is it possible to create Mac GUI applications without FireMonkey?
Possible Duplicate: rename multiple files at once in unix I would like to rename
Possible Duplicate: Opening url in new tab while i am doing window.open(), my page
Possible Duplicate: Why do programs in Unix-like environments have numbers after their name? I
Possible Duplicate: Shell Script: How to pass command line arguments to an UNIX alias?
Possible Duplicate: unix shell, getting exit code with piped child is it possible to
Possible Duplicate: Convert a Unix timestamp to time in Javascript Turn a unix timestamp
Possible Duplicate: Is it possible to get UNIX time from such date 2011-02-27 02:04:46?
Possible Duplicate: Subtracting dates in PHP I have two Unix timestamps, how can I

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.